2

I have a Kotlin library that I want to publish to Maven repository and use in other applications.

But when I add it as dependency (to pom.xml) in my Kotlin app I get this warning:

[WARNING] Some JAR files in the classpath have the Kotlin Runtime library bundled into them.
This may cause difficult to debug problems if there's a different version of the
Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath
or use '-Xskip-runtime-version-check' to suppress this warning
[WARNING] .........mylib.jar: (-1, -1) Library has Kotlin runtime bundled into it

What does it mean? Do I need to somehow exclude kotlin-stdlib from my library JAR? But what if I also want to use it in Java app?

Alex P.
  • 3,697
  • 9
  • 45
  • 110
  • Possibly related: https://youtrack.jetbrains.com/issue/KT-18398 – nhaarman Jun 29 '17 at 20:31
  • Did you try specifying `kotlin-stdlib` as a `provided` dependency in your library's pom? In theory this should allow to complie with Kotlin, but exclude it from the built package. – JK Ly Jun 29 '17 at 21:01

2 Answers2

0

Turns out it was just an issue specific to my library project.

I was using maven-shade-plugin to generate a "fat" JAR (containing all dependencies) which replaced the original JAR (so I deployed JAR with all dependencies bundled instead of just the library itself and list of dependencies) because it was also intended to be used as a simple console application.

So the solution is either to move the app to a separate project or to keep the original JAR (using <shadedArtifactAttached> + <shadedClassifierName> in the plugin configuration) and/or disable this plugin during deployment using Maven profiles as described here https://stackoverflow.com/a/39558669/964478.

Alex P.
  • 3,697
  • 9
  • 45
  • 110
0

I was facing a similar issue in my Kotlin app. The issue went away when I excluded the kotlin-stdlib library from the fat jar I was importing. If using the fat jar in a Java app, then dont exclude the dependency.

Pavan
  • 31
  • 2