Reputation: 17441
I have a Java project that incorporates some classes in Kotlin code. There are actually two Kotlin files, each in different folders and each a different package.
When doing a mvn clean package
, Kotlin file A is recognized and compiled into the project, but Kotlin file B is not.
Strangely, B was compiled in earlier, but I converted some Groovy files to Java to avoid Babel. Those new Java files reference the classes in B, and it is their compilation that is producing the errors.
I've checked and double-checked package names. To see if B's folder was being noticed by Maven, I even converted one of the data classes in B to Java and left it in the same folder. Suddenly that class was recognized.
What's going on here? Do I have a POM problem?
Upvotes: 0
Views: 1363
Reputation: 17441
I needed to add the following to my POM under the section for the Kotlin plug in:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<executions>
<!-- Replacing default-compile as it is treated specially by maven -->
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<!-- Replacing default-testCompile as it is treated specially by maven -->
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals> <goal>compile</goal> </goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals> <goal>testCompile</goal> </goals>
</execution>
</executions>
</plugin>
This was according to the the documentation here.
Upvotes: 1