Reputation: 2271
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!
Upvotes: 6
Views: 5970
Reputation: 97447
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...
Upvotes: 4