2010-04-08 60 views
6

我有一個項目內置在eclipse中,依賴於第三方jar。我試圖爲螞蟻生成一個合適的構建文件 - 使用內置的導出 - > ant構建文件功能作爲起始塊。Ant build classpath jar生成「在打開zip文件時出錯」

當我運行的構建目標,我得到了以下錯誤:

[javac] error: error reading /base/repo/FabTrace/lib/apache/geronimo/specs/geronimo-j2ee-management_1.0_spec/1.0/geronimo-j2ee-management_1.0_spec-1.0.jar; error in opening zip file 

而且整個構建文件(自動生成的日食)看起來是這樣的: (注:上面總是錯誤引用第一在類路徑中列出的JAR)

<project basedir="." default="build" name="FabTrace"> 
    <property environment="env"/> 
    <property name="ECLIPSE_HOME" value="/opt/apps/eclipse"/> 
    <property name="debuglevel" value="source,lines,vars"/> 
    <property name="target" value="1.5"/> 
    <property name="source" value="1.5"/> 
    <path id="JUnit 4.libraryclasspath"> 
     <pathelement location="${ECLIPSE_HOME}/plugins/org.junit4_4.5.0.v20090824/junit.jar"/> 
     <pathelement location="${ECLIPSE_HOME}/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"/> 
    </path> 
    <path id="FabTrace.classpath"> 
     <pathelement location="bin"/> 
     <pathelement location="lib/apache/geronimo/specs/geronimo-j2ee-management_1.0_spec/1.0/geronimo-j2ee-management_1.0_spec-1.0.jar"/> 
     <pathelement location="lib/apache/geronimo/specs/geronimo-jms_1.1_spec/1.0/geronimo-jms_1.1_spec-1.0.jar"/> 
     <pathelement location="lib/commons-collections/commons-collections/3.2/commons-collections-3.2.jar"/> 
     <pathelement location="lib/commons-io/commons-io/1.4/commons-io-1.4.jar"/> 
     <pathelement location="lib/commons-lang/commons-lang/2.1/commons-lang-2.1.jar"/> 
     <pathelement location="lib/commons-logging/commons-logging/1.1/commons-logging-1.1.jar"/> 
     <pathelement location="lib/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar"/> 
     <pathelement location="lib/javax/activation/activation/1.1/activation-1.1.jar"/> 
     <pathelement location="lib/javax/jms/jms/1.1/jms-1.1.jar"/> 
     <pathelement location="lib/javax/mail/mail/1.4/mail-1.4.jar"/> 
     <pathelement location="lib/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar"/> 
     <pathelement location="lib/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar"/> 
     <pathelement location="lib/junit/junit/4.4/junit-4.4.jar"/> 
     <pathelement location="lib/log4j/log4j/1.2.15/log4j-1.2.15.jar"/> 
     <pathelement location="lib/apache/camel/camel-jms-2.0-M1.jar"/> 
     <pathelement location="lib/spring/spring-2.5.6.jar"/> 
     <pathelement location="lib/apache/camel/camel-bundle-2.0-M1.jar"/> 
     <pathelement location="lib/backport-util-concurrent/backport-util-concurrent-3.1.jar"/> 
     <pathelement location="lib/commons-pool/commons-pool-1.4.jar"/> 
     <pathelement location="lib/apache/camel/camel-activemq-1.1.0.jar"/> 
     <pathelement location="lib/apache/activemq/activemq-camel-5.2.0.jar"/> 
     <pathelement location="lib/jencks/jencks-2.2-all.jar"/> 
     <pathelement location="lib/jencks/jencks-amqpool-2.2.jar"/> 
     <pathelement location="lib/activemq/apache-activemq-5.3.1/activemq-all-5.3.1.jar"/> 
     <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/optional/xbean-spring-3.6.jar"/> 
     <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/activemq-core-5.3.1.jar"/> 
     <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/camel-jetty-2.2.0.jar"/> 
     <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/web/jetty-6.1.9.jar"/> 
     <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/web/jetty-util-6.1.9.jar"/> 
     <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/web/jetty-xbean-6.1.9.jar"/> 
     <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/optional/activemq-optional-5.3.1.jar"/> 
     <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/web/geronimo-servlet_2.5_spec-1.2.jar"/> 
     <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/optional/spring-beans-2.5.6.jar"/> 
     <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/optional/spring-context-2.5.6.jar"/> 
     <pathelement location="lib/activemq/apache-activemq-5.3.1/lib/optional/spring-core-2.5.6.jar"/> 
     <path refid="JUnit 4.libraryclasspath"/> 
    </path> 
    <target name="init"> 
     <mkdir dir="bin"/> 
     <copy includeemptydirs="false" todir="bin"> 
      <fileset dir="src/main/java"> 
       <exclude name="**/*.launch"/> 
       <exclude name="**/*.java"/> 
      </fileset> 
     </copy> 
     <copy includeemptydirs="false" todir="bin"> 
      <fileset dir="src/test/java"> 
       <exclude name="**/*.launch"/> 
       <exclude name="**/*.java"/> 
      </fileset> 
     </copy> 
     <copy includeemptydirs="false" todir="bin"> 
      <fileset dir="config"> 
       <exclude name="**/*.launch"/> 
       <exclude name="**/*.java"/> 
      </fileset> 
     </copy> 
    </target> 
    <target name="clean"> 
     <delete dir="bin"/> 
    </target> 
    <target depends="clean" name="cleanall"/> 
    <target depends="build-subprojects,build-project" name="build"/> 
    <target name="build-subprojects"/> 
    <target depends="init" name="build-project"> 
     <echo message="${ant.project.name}: ${ant.file}"/> 
     <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}"> 
      <src path="src/main/java"/> 
      <classpath refid="FabTrace.classpath"/> 
     </javac> 
     <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}"> 
      <src path="src/test/java"/> 
      <classpath refid="FabTrace.classpath"/> 
     </javac> 
     <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}"> 
      <src path="config"/> 
      <classpath refid="FabTrace.classpath"/> 
     </javac> 
    </target> 

</project> 

(我知道有一個在這裏蝕具體的東西,但我得到相同的結果有或沒有它。)

我已經完成了你的舊谷歌搜索和拖網沒有成功。

我可以證實所有的罐子確實存在。我也嘗試從命令行和sudo - 同樣的結果。

任何幫助將不勝感激。

乾杯

+2

jar文件是否有效?你可以在WinZip或其他壓縮工具中打開它嗎? – VonC 2010-04-08 16:14:59

+0

感嘆。我想到了,因爲我已經移除了最初導致這個問題的第一批罐子(我甚至不相信我真的需要它們),問題剛剛轉移到下一個罐子......好吧,這讓我很懷疑係統性缺陷。 原來我確實在classpath上有很多垃圾罐。必須在某個時候搞砸了一個下載或什麼東西。 無論如何,現在全部修好了。乾杯 – 2010-04-09 07:56:28

+0

爲什麼不把你的評論移到答案然後接受它?這可能被證明對某個人來說是一個有用的問題,但目前它顯示爲「未答覆」。 – 2011-06-24 12:18:01

回答

3

根據Martin Clayton的建議,我之前的評論在下面被複製作爲答案。

「嘆了口氣,我想到因爲我刪除了最初導致這個問題的第一個瓶子(我甚至不相信我真的需要它們),問題剛剛轉移到下一個罐子。嗯,這讓我懷疑係統性的錯誤,結果我確實在班級路徑上有很多垃圾罐,必須在某個時候搞砸了一個下載或者什麼東西,無論如何,現在都已經修好了,乾杯「

+0

我有大量隱藏的罐子(。!79974!google-play-services.jar)導致這個問題,謝謝你的想法! – rob5408 2015-02-27 23:20:22

0

是否有任何在生成文件中複製語句<filterset/>?我遇到了一個問題,曾經是我在<copy> -ing「**/*」之後,並且在開發的最後,我想出瞭如何使用<filterset/><copy>

長話短說,文本替換工作完美無瑕,但是在「**/*」路徑中的任何二進制文件,可執行文件或.jar都完全被破壞。而不是以二進制模式打開文件,它們以文本模式打開,然後以文本模式保存。

如果您的編譯文件中有任何<filterset/>或類似的東西,請確保<exclude/>任何及所有二進制文件。

相關問題