2011-07-23 29 views
4

在使用Leiningen,我得到了以下錯誤突然:在線程如何從leiningen項目中排除罐子?

異常 「主要」 java.lang.NoSuchMethodError:org.apache.tools.ant.util.FileUtils.getFileUtils()Lorg /阿帕奇/工具/螞蟻/ UTIL /文件實用程序; (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)在上面標記爲的行中,我無法說出如何排除特定版本的jar文件。

2)在,以上,究竟是什麼bin/lein?我的Leiningen項目沒有bin目錄,而Leiningen本身就是一個腳本,所以那裏沒有bin目錄?

非常感謝您的幫助。


附錄11年8月6日:對於有車博士的具體問題,我發現車博士的叉能解決問題對我來說。只需將「[org.clojars.weavejester/autodoc」0.9.0「]」添加到project.clj> defproject>:dev-dependencies子句。然後,從命令行(目錄等於您的leiningen項目的根目錄)執行'lein autodoc',然後等待一段時間。

回答

8

回答(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中引用的目錄的順序來解決問題。