We have enabled the Kotlin Maven plug-in in our top-most project POM, like this:
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>process-test-sources</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
ATM, only a handful of the modules in this project have Kotlin source code. (The project is around 50 modules.) The idea is that most will eventually have Kotlin code, and we don't want to have to wire things up on a per project basis. We want to configure it once, and forget about it.
This works except that we get this warning in the build for most modules:
[INFO] Kotlin Compiler version 1.0.2
[WARNING] No sources found skipping Kotlin compile
We had this problem with the JAR plug-in as well. That plug-in has a configuration option that allows us to do like this:
<configuration>
<skipIfEmpty>true</skipIfEmpty>
</configuration>
This shutup that plug-in's similar warnings. The Kotlin compiler plug-in doesn't seem to have any such config option though.
So, my questions are:
TIA!
The kotlin-maven-plugin compiles Kotlin sources and modules. Currently, only Maven v3 is supported.
If you still prefer to stick with good old Maven, there is no problem. There is a plugin for it to support Kotlin as well. If you don't have Maven on your machine, you can follow the instructions at https://maven.apache.org/install.html to get it installed on your local machine.
Yes. Kotlin is 100% interoperable with the Java programming language and major emphasis has been placed on making sure that your existing codebase can interact properly with Kotlin. You can easily call Kotlin code from Java and Java code from Kotlin. This makes adoption much easier and lower-risk.
Plugins are the central feature of Maven that allow for the reuse of common build logic across multiple projects. They do this by executing an "action" (i.e. creating a WAR file or compiling unit tests) in the context of a project's description - the Project Object Model (POM).
The default way to handle such things is to define the configuration like you have in the parent of the project via pluginManagement
which prevents it's being inherited for all modules which is not correct. Than in those modules which are using Kotlin you need to add a few lines to the pom file:
<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
If the kotlin-maven-plugins contains such option i can't tell you cause i didn't find the source code of it nor does there exist a maven generated site which contains all the defaults and the options etc. which is not the case (Not really good)..
Or an other solution would be to change the kotlin-maven-plugin having it's own life cycle which means to change the code of the plugin...and just change the <packaging>kotlin</packaging>
of those modules...which is work for the original authors to do...
If you have needed to add the option <skipIfEmpty>..</skipIfEmpty>
for the maven-jar-plugin this sounds wrong as well...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With