2014-10-05 35 views
0

我已經打開了一個在eclipse env中有build.xml和ivy.xml的項目。 後我申請運行方式..>螞蟻通過右鍵點擊build.xml中建,我面臨過這樣的錯誤:由build.xml構建目標時出錯

BUILD FAILED 
Target "retrieve" does not exist in the project "aaa". It is used from target "compile". 

我的build.xml文件:

<project name="WOE" default="build"> 

    <!--<import file="../build/ivy-targets.xml"/>--> 

    <property name="dir.base" location="."/> 
    <!--<property name="dir.repos" location="${dir.base}/../repository/modules"/>--> 
    <property name="dir.src" location="${dir.base}/src/java"/> 
    <property name="dir.lib" location="${dir.base}/src/lib"/> 
    <property name="dir.ivy.lib" location="${dir.base}/lib"/> 
    <property name="dir.build" location="${dir.base}/build"/> 
    <property name="dir.classes" location="${dir.build}/classes"/> 
    <property name="module.jar" location="${dir.build}/WOEParse.jar"/> 

    <property name="dir.doc" location="${dir.base}/doc"/> 
    <property name="dir.javadoc" location="${dir.doc}/api"/> 

    <path id="classpath"> 
     <fileset dir="${dir.lib}" includes="*.jar"/> 
     <fileset dir="${dir.ivy.lib}/default" includes="*.jar"/> 
     <!--<pathelement path="${dir.repos}/edu.stanford/BaselineNLProcessor/521/jars/baseline-nlprocessor-2010-06-22-521.jar" />--> 
    </path> 

    <path id="run.classpath"> 
     <path refid="classpath"/> 
     <pathelement location="${module.jar}"/> 
    </path> 

    <target name="clean" description="Deletes artifacts produced by build"> 
     <delete dir="${dir.build}"/> 
     <delete dir="${dir.javadoc}"/> 
     <delete dir="${dir.ivy.lib}"/> 
    </target> 

    <target name="compile" depends="retrieve" description="Compiles source code"> 
     <mkdir dir="${dir.classes}"/> 
     <javac destdir="${dir.classes}" 
       debug="true" 
       target="1.6"> 
      <classpath refid="classpath"/> 
      <src path="${dir.src}"/> 
     </javac> 

    </target> 

    <target name="build" depends="compile" description="Builds module JAR file"> 
     <jar jarfile="${module.jar}"> 
      <fileset dir="${dir.classes}" includes="**/*.class"/> 
      <manifest> 
       <attribute name="Built-By" value="${user.name}"/> 
      </manifest> 
     </jar> 
    </target> 

    <target name="run" depends="build" description="Processes a simple example file"> 
     <java classname="edu.washington.cs.woe.WOEParse" fork="true" failonerror="true"> 
      <jvmarg value="-Xmx1G"/> 
      <classpath refid="run.classpath"/> 
      <arg line="-inFile ./light-config/data/testSentenceFile -cfDir ./light-config/"/> 
     </java> 
    </target> 

    <target name="javadoc" description="Builds javadoc html files for this source code"> 
     <mkdir dir="${dir.javadoc}"/> 
     <javadoc classpathref="classpath" destdir="${dir.javadoc}" sourcepath="${dir.src}"> 
      <packageset dir="${dir.src}" defaultexcludes="yes"> 
      </packageset> 
     </javadoc> 
    </target> 


</project> 

是發生在這一部分的錯誤:

enter image description here

我改成了

<target name="compile" description="Compiles source code"> 

但它顯示了另一個錯誤:

Buildfile: D:\eclipse workspace\WOE\build.xml 
compile: 
    [mkdir] Created dir: D:\eclipse workspace\WOE\build\classes 
    [javac] D:\eclipse workspace\WOE\build.xml:38: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds 
    [javac] Compiling 42 source files to D:\eclipse workspace\WOE\build\classes 

BUILD FAILED 
D:\eclipse workspace\WOE\build.xml:38: D:\eclipse workspace\WOE\lib\default does not exist. 

Total time: 328 milliseconds 

我該怎麼辦? eclipse env有沒有問題?(我在eclipse中沒有任何ant插件等),如果是這樣的話,我應該在eclipse中使用哪個插件來正確打開這樣的項目?

請幫幫我。 感謝

+1

顯示我們的build.xml – 2014-10-05 16:13:31

+0

@格雷格-449:好的。我做的。 – BlueGirl 2014-10-05 16:46:57

回答

1

的錯誤是在這裏:

<target name="compile" depends="retrieve" 

要麼宣佈的目標名稱爲「檢索」或刪除的依賴。

+0

你的意思我將其更改爲: <目標名稱=「編譯」描述=「編譯源代碼」> 或者 <目標名稱=「檢索」描述=「編譯源代碼」> 不有整個項目的破壞性影響? 我沒有關於目標的知識! – BlueGirl 2014-10-05 16:35:24

1

這是從另一個構建文件複製n粘貼創建的構建文件?

第一個問題

你有一個依賴於另一個叫不存在的目標編譯目標「檢索」

<target name="compile" depends="retrieve" description="Compiles source code"> 
    <mkdir dir="${dir.classes}"/> 
    <javac destdir="${dir.classes}" 
      debug="true" 
      target="1.6"> 
     <classpath refid="classpath"/> 
     <src path="${dir.src}"/> 
    </javac> 
</target> 

當使用常春藤這是很常見的目標是首先解析(下載,如果必要)第三方jar依賴關係。這是編譯你的代碼所必需的。

第二期

你的第二個錯誤是由您的構建以下部分拋出:

<path id="classpath"> 
    <fileset dir="${dir.lib}" includes="*.jar"/> 
    <fileset dir="${dir.ivy.lib}/default" includes="*.jar"/> 
    <!--<pathelement path="${dir.repos}/edu.stanford/BaselineNLProcessor/521/jars/baseline-nlprocessor-2010-06-22-521.jar" />--> 
</path> 

代碼是希望找到在$ {} dir.ivy.lib瓶/默認目錄。推測這是作爲缺失檢索任務的一部分發生的。

使用常春藤的工作示例

希望這會有所幫助。

0

轉到偏好,勾選 「忽略所有構建文件問題」。

https://i.stack.imgur.com/8SiqM.png