如何从 leiningen 项目中排除 jars? [英] How do I exclude jars from a leiningen project?

查看:23
本文介绍了如何从 leiningen 项目中排除 jars?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 Leiningen 时,我遇到了以下突然错误:

While using Leiningen, I got the following abrupt error:

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

Exception in thread "main" 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/上阅读了 Leiningen 教程technomancy/leiningen/blob/master/doc/TUTORIAL.mdhttps://github.com/technomancy/leiningen/blob/stable/sample.project.clj,但我还有以下问题:

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:

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

1) At the line marked 1, above, I can't tell how to exclude a specific version of a jar file.

2) 在上面的 2 处,bin/lein 究竟是什么?我的Leiningen项目没有bin目录,而Leiningen本身就是一个脚本,所以那里没有bin目录?

2) At 2, above, exactly what is bin/lein? My Leiningen project doesn't have a bin directory, and Leiningen itself is a script, so there's no bin directory there?

非常感谢您的帮助.

附录 8/6/11:对于 Autodoc 的具体问题,我找到了 Autodoc 的一个分支,它为我解决了这个问题.只需将 "[org.clojars.weavejester/autodoc "0.9.0"]" 添加到 project.clj > defproject > :dev-dependencies 子句.然后,从命令行(目录等于您的 leiningen 项目的根目录),执行 'lein autodoc',并等待一段时间.

Addendum 8/6/11: For the specific problem with Autodoc, I found a fork of Autodoc that fixes the problem for me. Just add "[org.clojars.weavejester/autodoc "0.9.0"]" to project.clj > defproject > :dev-dependencies clause. Then, from the command line (with the directory equal to the root of your leiningen project), execute 'lein autodoc', and wait for a while.

推荐答案

在回答 (1) 我不确定他是否说您需要排除特定版本的 Ant,但更有可能您可以修复通过排除 Autodoc 引入的 Ant 版本(无论是什么版本)来解决问题.您可以尝试以下操作:

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

我只是在此处的开发依赖项中排除了它,假设 Autodoc 仅在构建期间使用.

I've only excluded it in dev-dependencies here, assuming that Autodoc is only to be used during a build.

对于 (2),你是对的,Leiningen 是一个脚本,但在问题报告中,作者建议编辑 Leiningen 脚本以通过更改 Leiningen 的 CLASSPATH 中引用的目录顺序来解决问题.

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.

这篇关于如何从 leiningen 项目中排除 jars?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆