简体   繁体   English

如何从 leiningen 项目中排除 jars?

[英]How do I exclude jars from a leiningen project?

While using Leiningen, I got the following abrupt error:使用 Leiningen 时,出现以下突发错误:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.tools.ant.util.FileUtils.getFileUtils()Lorg/apache/tools/ant/util/FileUtils;线程“main”中的异常 java.lang.NoSuchMethodError: org.apache.tools.ant.util.FileUtils.getFileUtils()Lorg/apache/tools/ant/util/FileUtils; (core.clj:1) (核心.clj:1)

I found the following answer at https://github.com/technomancy/leiningen/issues/194 :我在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"

I read the Leiningen tutorial at https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md and the sample project.clj file at https://github.com/technomancy/leiningen/blob/stable/sample.project.clj , but I still have the following questions:我在 https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md 阅读了 Leiningen 教程,在https://github.com/technomancy/leiningen/blob/stable 阅读了示例 project.clj 文件/sample.project.clj ,但我仍然有以下问题:

1) At the line marked 1 , above, I can't tell how to exclude a specific version of a jar file. 1) 在上面标记为1的行中,我不知道如何排除 jar 文件的特定版本。

2) At 2 , above, exactly what is bin/lein ? 2) 在上面的2处, bin/lein到底是什么? My Leiningen project doesn't have a bin directory, and Leiningen itself is a script, so there's no bin directory there?我的Leiningen项目没有bin目录,而Leiningen本身就是一个脚本,所以那里没有bin目录?

Many thanks for your help.非常感谢您的帮助。


Addendum 8/6/11: For the specific problem with Autodoc, I found a fork of Autodoc that fixes the problem for me.附录 8/6/11:对于 Autodoc 的具体问题,我找到了 Autodoc 的一个分支,它为我解决了这个问题。 Just add "[org.clojars.weavejester/autodoc "0.9.0"]" to project.clj > defproject > :dev-dependencies clause.只需将“[org.clojars.weavejester/autodoc“0.9.0”]”添加到 project.clj > defproject > :dev-dependencies子句。 Then, from the command line (with the directory equal to the root of your leiningen project), execute 'lein autodoc', and wait for a while.然后,从命令行(目录等于您的 leiningen 项目的根目录)执行“lein autodoc”,并等待一会儿。

In answer to (1) I'm not sure if he's saying that you need to exclude a specific version of Ant, but more likely that you can fix the issue by excluding the version of Ant that's pulled in by Autodoc (no matter what version).在回答 (1) 我不确定他是否说你需要排除特定版本的 Ant,但更有可能你可以通过排除 Autodoc 引入的 Ant 版本来解决这个问题(无论什么版本). You could try something like:你可以尝试这样的事情:

(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]]])

I've only excluded it in dev-dependencies here, assuming that Autodoc is only to be used during a build.我在这里只将它排除在开发依赖项中,假设 Autodoc 仅在构建期间使用。

For (2), you are correct, Leiningen is a script, but in the issue report, the author is suggesting an edit to the Leiningen script to fix the issue by changing the order of directories referenced in Leiningen's CLASSPATH.对于 (2),你是对的,Leiningen 是一个脚本,但在问题报告中,作者建议编辑 Leiningen 脚本以通过更改 Leiningen 的 CLASSPATH 中引用的目录顺序来解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM