且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

编写插件时,如何排除leiningen引入的依赖项?

更新时间:2022-12-12 20:51:22

第一个问题:这是一个已知问题吗?

First question: is this a known issue?

这是一个已知问题,许多编写Leiningen插件的人都会遇到这个问题.根本原因是Leiningen用其所有依赖项构建了一个uberjar,而这些依赖项不是阴影.这意味着,如果杰克逊班级之间发生冲突,将始终选择莱宁根的班级.使得这种情况特别令人反感的是,您不会收到有关冲突依赖项的任何警告,因为JAR不会发生冲突,但是它们的内容却会发生冲突.

This is a known issue, and one that many people writing Leiningen plugins face. The root cause is that Leiningen builds an uberjar with all of its dependencies, and those dependencies are not shaded. This means that if there is any collision between Jackson classes, Leiningen's one will always be chosen. What makes this especially devious is that you won't get any warnings about conflicting dependencies, as the JARs don't conflict, but the contents of them do.

以下是此问题的一些示例: https://github.com/s3-wagon-private/s3-wagon-private/issues/38

Here's a few examples of this problem: https://github.com/s3-wagon-private/s3-wagon-private/issues/38, https://github.com/technomancy/leiningen/issues/2215.

第二:有人对解决此问题有任何建议吗?

Second: Does anyone have any suggestions for working around this problem?

在同一个库的不同主要版本中具有Clojure相互依赖关系的问题对于一般情况有一些建议,尽管在Lein的依赖关系被超级压缩时会变得有些棘手.

Issues with Clojure inter-dependency with different major versions of the same library has some suggestions for the general case, although it gets a little trickier when Lein's dependencies are uberjarred.

我认为此时***的选择是隐藏Jackson依赖项和AWS开发工具包.

I think your best bet at this point would be to shade the Jackson dependency and the AWS SDK.

莱宁根大师不再依赖于柴郡,并且当2.8.0是释放您应该有较少的问题.

Leiningen master no longer depends on Cheshire though, and when 2.8.0 is released you should have less problems.