创建和发布Kotlin库以避免多个运行时问题的正确方法是什么?

我有一个Kotlin库,我想发布到Maven仓库,并在其他应用程序中使用。

但是,当我把它作为依赖(到pom.xml )在我的Kotlin应用程序中添加时,我得到这个警告:

 [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 

这是什么意思? 我需要以某种方式从我的库JAR中排除kotlin-stdlib吗? 但是,如果我也想在Java应用程序中使用它呢?

原来这只是我的图书馆项目特有的问题。

我使用maven-shade-plugin来生成一个替换了原始JAR的“胖”JAR(包含所有的依赖关系)(因此,我部署了所有依赖关系的JAR,而不仅仅是库本身和依赖关系列表)被用作一个简单的控制台应用程序。

因此,解决方案是将应用程序移动到单独的项目或保留原始JAR(在插件配置中使用<shadedArtifactAttached> + <shadedClassifierName> )和/或在部署过程中使用Maven配置文件禁用此插件,如https:/ / /stackoverflow.com/a/39558669/964478 。