我如何从leiningen项目中排除jar?

问题描述 投票:6回答:2

使用雷宁根时,出现以下突然错误:

线程“主”中的异常java.lang.NoSuchMethodError:org.apache.tools.ant.util.FileUtils.getFileUtils()Lorg / apache / tools / ant / util / FileUtils; (core.clj:1)

我在https://github.com/technomancy/leiningen/issues/194找到了以下答案:

if ant version 1.6.1 is included in a project, lein fails. Autodoc "0.7.1" includes ant version 1.6.1.

a work around is to exclude ant.1.6.1 in the project.clj.    <--- *1*
But a better solution is changing the order of lein classpath.

from bin/lein   <--- *2*
CLASSPATH="$CLASSPATH:$LEIN_LIBS:$LEIN_DIR/src:$LEIN_DIR/classes:$LEIN_DIR/resources:$LEIN_JAR"
**changes to : **
CLASSPATH="$LEIN_LIBS:$LEIN_DIR/src:$LEIN_DIR/classes:$LEIN_DIR/resources:$LEIN_JAR;$CLASSPATH"

我在https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md阅读了Leiningen教程,在https://github.com/technomancy/leiningen/blob/stable/sample.project.clj阅读了示例project.clj文件,但是我仍然有以下问题:

1]在上面标记为1的行上,我不知道如何排除特定版本的jar文件。

2]在上面的[[2中,bin/lein到底是什么?我的Leiningen项目没有bin目录,Leiningen本身是一个脚本,所以那里没有bin目录?

非常感谢您的帮助。


附录8/6/11:对于Autodoc的特定问题,我找到了一个Autodoc分支来为我解决此问题。只需将“ [org.clojars.weavejester / autodoc“ 0.9.0”]”添加到project.clj> defproject> :dev-dependencies子句。然后,从命令行(目录与leiningen项目的根目录相同)执行“ lein autodoc”,并等待一会儿。

clojure jar leiningen autodoc
2个回答
12
投票
回答(1),我不确定他是否在说您需要排除特定版本的Ant,但更有可能您可以通过排除由Autodoc引入的Ant版本来解决此问题(无论什么版本)。您可以尝试以下方法:

(defproject my-project "1.0.0" :dependencies [[org.clojure/clojure "1.2.0"]                 [org.clojure/clojure-contrib "1.2.0"]] :dev-dependencies [[autodoc "0.7.1" :exclusions [org.apache.ant/ant]]])

这里我仅在开发依赖项中将其排除,假设Autodoc仅在构建期间使用。

对于(2),您是正确的,Leiningen是脚本,但是在问题报告中,作者建议对Leiningen脚本进行编辑,以通过更改Leiningen的CLASSPATH中引用的目录顺序来解决此问题。


0
投票
project.clj下的:dependencies中,您可以为特定的jar添加排除项,如下所示:

[[test / test-jar“ 1.0”:排除项[sample-exclusion / test-exclusions]]

© www.soinside.com 2019 - 2024. All rights reserved.