I tried to use Kotlin with Maven so I followed the documentation
I have this configuration in the pom.xml
file
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<kotlin.version>1.2.10</kotlin.version>
</properties>
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
The sources folders are src/main/kotlin
and src/test/kotlin
When I do mvn clean install
I got this error
[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.2.10:compile (compile) on project kotlin-starter: Execution compile of goal org.jetbrains.kotlin:kotlin-maven-plugin:1.2.10:compile failed: A required class was missing while executing org.jetbrains.kotlin:kotlin-maven-plugin:1.2.10:compile: kotlin/reflect/KDeclarationContainer
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.jetbrains.kotlin:kotlin-maven-plugin:1.2.10
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
...
I also tried using kotlin-stdlib
instead of kotlin-stdlib-jdk8
but I got the same error. When I open the library I see the classKDeclarationContainer
in the package kotlin.reflect
so I don't understand why I got this error ?
EDIT : when I change kotlin version to <kotlin.version>1.1.61</kotlin.version>
, everything works perfectly...
I had a very similar issue with kotlin-maven-plugin/1.2.20 which went away after I deleted org/jetbrains out of my local maven repo and re-ran the build. I can only think something was corrupted or missing.
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