I have found this similar question regarding Android, but I am using plain Java with Maven as build tool. I think it is better to post a new question.
I have created a Kotlin class to which I am trying to refer from Java class as MyKotlinClass.class
. The Maven build fails, whereas compilation in IntelliJ Idea works fine. I have already added Kotlin plugin to maven:
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
However that does not help:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project app: Compilation failure
[ERROR] MyClassLinkingKotlin.java:[100,40] error: cannot find symbol
The line/column exactly refers to symbol MyKotlinClass.class
. It will fail even when using like this:
System.err.println(MyKotlinClass.class)
MyClassLinkingKotlin.java
particularly line 100 (I think its [line,col]) – Selfconsequence