Maven dependency using Kotlin not bringing in Kotlin classes

Viewed 2061

I have two projects, one which is a dependency on the other. I've converted the dependency project over to Kotlin, but now when maven pulls the published dependency from my local maven repository the parent project is not taking in the Kotlin internal libraries that the dependency needs.

Outline:
Main Project
  ↳ Now-Kotlin Project
          ↳ Kotlin Std-lib

This results in a java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics exception when running the main project.

The now-Kotlin project has the kotlin-maven-plugin plugin and the kotlin-stdlib defined in it's pom.xml.

The parent project has the now-Kotlin project listed as a dependency, and it is imported correctly, it's classes found and used, etc... in IntelliJ just fine.

Compiling and startup of the main project's application on tomcat works correctly until the first invocation of code from the now-Kotlin project, which results in

org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
....
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics

My assumption is that the Kotlin libraries would follow normal dependency rules for Maven and that the org.jetbrains.kotlin packages from kotlin-stdlib would be included the same as any transitive dependency.

What is the right way to get these dependencies included into the main project?

Update

Main Project mvn dependency:tree relevant portion:

[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ example-core ---
[INFO] com.example:example-core:jar:1.17.0-SNAPSHOT
[INFO] +- com.example.service.search:search-client:jar:kotlin:2.0.3-SNAPSHOT:compile

Main Project POM

...
<dependency>
    <groupId>com.example.service.search</groupId>
    <artifactId>search-client</artifactId>
    <version>2.0.3-SNAPSHOT</version>
    <scope>compile</scope>
</dependency>
...

New Kotlin Project POM

...
<properties>
    <kotlin.version>1.1.2-2</kotlin.version>
</properties>
...
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-test</artifactId>
            <version>${kotlin.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
...
<build>
    <plugins>
        <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>
    </plugins>
</build>
0 Answers
Related