簡體   English   中英

Ant構建失敗,沒有可見錯誤

[英]Ant build fails with no visible errors

編輯:我最終在Eclipse中設置了整個項目,並且能夠構建它。 我不確定為什么會出現這個問題,希望我永遠不會發現。

我遇到問題,我的構建報告“BUILD FAILED”而沒有報告任何錯誤。

我正在構建大量舊代碼的大型應用程序,現在我很樂意修改它。 大多數其他開發人員已經使用Eclipse設置了他們的構建,但我正在嘗試通過現有的build.xml文件來構建它。

獲取我的類路徑后,構建運行順利,但在開始編譯步驟后不久,它返回:

 Lots of "[javac] file.java" lines. BUILD FAILED <project path>/build.xml:201: Compile failed; see the compiler error output for details. 

這不是很有用。 除了堆棧跟蹤之外,build.log沒有其他信息:

 at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1085) at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:885) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) at org.apache.tools.ant.Project.executeTarget(Project.java:1306) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1189) at org.apache.tools.ant.Main.runBuild(Main.java:758) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) 

-debug標志添加到ant會創建大量信息,並且使用如此長的類路徑(如此多的罐子),很難對其進行排序。

這是螞蟻的目標:

  <target name="compile" depends="achmetadata"> <mkdir dir="${path.build.classes}"/> <javac listfiles="yes" destdir="${path.build.classes}" classpathref="project.classpath" debug="on" deprecation="on" fork="yes" nowarn="no" memoryMaximumSize="512M" srcdir="${path.src.java}" source="1.4" target="1.4" > -><src path="${path.build.src}"/> <patternset refid="production-code"/> </javac> </target> 

類路徑是通過classpathref設置的,並且通過和標簽包含了很多jar。

關於我應該看什么的任何想法? 會導致螞蟻失敗的原因是什么?

應該在build.xml本身內部設置CLASSPATH。 如果你依賴於CLASSPATH環境變量,那你就犯了一個錯誤。

看看這個build.xml是否更好。 研究目錄結構並使其與build.xml中拼寫的匹配:

<?xml version="1.0" encoding="UTF-8"?>
<project name="xslt-converter" basedir="." default="package">

    <property name="version" value="1.6"/>
    <property name="haltonfailure" value="no"/>

    <property name="out" value="out"/>

    <property name="production.src" value="src"/>
    <property name="production.lib" value="lib"/>
    <property name="production.resources" value="config"/>
    <property name="production.classes" value="${out}/production/${ant.project.name}"/>

    <property name="test.src" value="test"/>
    <property name="test.lib" value="lib"/>
    <property name="test.resources" value="config"/>
    <property name="test.classes" value="${out}/test/${ant.project.name}"/>

    <property name="exploded" value="out/exploded/${ant.project.name}"/>
    <property name="exploded.classes" value="${exploded}/WEB-INF/classes"/>
    <property name="exploded.lib" value="${exploded}/WEB-INF/lib"/>

    <path id="production.class.path">
        <pathelement location="${production.classes}"/>
        <pathelement location="${production.resources}"/>
        <fileset dir="${production.lib}">
            <include name="**/*.jar"/>
            <exclude name="**/junit*.jar"/>
            <exclude name="**/*test*.jar"/>
        </fileset>
    </path>

    <path id="test.class.path">                            
        <path refid="production.class.path"/>
        <pathelement location="${test.classes}"/>
        <pathelement location="${test.resources}"/>
        <fileset dir="${test.lib}">
            <include name="**/junit*.jar"/>
            <include name="**/*test*.jar"/>
        </fileset>
    </path>

    <path id="testng.class.path">
        <fileset dir="${test.lib}">
            <include name="**/testng*.jar"/>
        </fileset>
    </path>

    <available file="${out}" property="outputExists"/>

    <target name="clean" description="remove all generated artifacts" if="outputExists">
        <delete dir="${out}" includeEmptyDirs="true"/>
        <delete dir="${reports.out}" includeEmptyDirs="true"/>
    </target>

    <target name="create" description="create the output directories" unless="outputExists">
        <mkdir dir="${production.classes}"/>
        <mkdir dir="${test.classes}"/>
        <mkdir dir="${reports.out}"/>
        <mkdir dir="${junit.out}"/>
        <mkdir dir="${testng.out}"/>
        <mkdir dir="${exploded.classes}"/>
        <mkdir dir="${exploded.lib}"/>
    </target>

    <target name="compile" description="compile all .java source files" depends="create">
        <!-- Debug output
                <property name="production.class.path" refid="production.class.path"/>
                <echo message="${production.class.path}"/>
        -->
        <javac srcdir="src" destdir="${out}/production/${ant.project.name}" debug="on" source="${version}">
            <classpath refid="production.class.path"/>
            <include name="**/*.java"/>
            <exclude name="**/*Test.java"/>
        </javac>
        <javac srcdir="${test.src}" destdir="${out}/test/${ant.project.name}" debug="on" source="${version}">
            <classpath refid="test.class.path"/>
            <include name="**/*Test.java"/>
        </javac>
    </target>

</project>

你可以在調試模式下運行你的ant構建,以便你可以單步執行它嗎? 在build.xml中設置斷點。 然后右鍵單擊build.xml並選擇Debug As - > Ant Build(假設您正在使用Eclipse)。 這可能有助於您找出問題所在。

HTH。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM