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



我有一个我想发布到maven存储库并在其他应用程序中使用的kotlin库。

但是,当我在kotlin应用中将其添加为依赖项(将其添加到pom.xml(时,我会收到此警告:

[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

这是什么意思?我需要以某种方式从图书馆罐中排除kotlin-stdlib?但是,如果我也想在Java应用中使用它怎么办?

事实证明这只是我库项目的一个问题。

我正在使用 maven-shade-plugin生成一个"胖"罐(包含所有依赖项(,该罐子替换了原始jar(所以我用捆绑的所有依赖项部署了jar,而不是仅仅是库本身和依赖项列表(,因为它也旨在用作简单的控制台应用程序。

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

我在我的Kotlin应用程序中面临类似的问题。当我将Kotlin-Stdlib图书馆从我正在进口的胖罐中排除时,问题就消失了。如果在Java应用中使用胖罐,则不要排除依赖关系。

最新更新