简体   繁体   English

Ant构建失败,没有可见错误

[英]Ant build fails with no visible errors

EDIT: I ended up setting up the whole project in Eclipse and was able to get it to build. 编辑:我最终在Eclipse中设置了整个项目,并且能够构建它。 I'm not sure why this problem occurred and hopefully I'll never have to find out. 我不确定为什么会出现这个问题,希望我永远不会发现。

I'm having a problem where my build is reporting "BUILD FAILED" without reporting any errors. 我遇到问题,我的构建报告“BUILD FAILED”而没有报告任何错误。

I'm building a large application of a lot of old code which I now have the joy of modifying. 我正在构建大量旧代码的大型应用程序,现在我很乐意修改它。 Most of the other developers have set up their builds with Eclipse, but I'm trying to build it through the existing build.xml files. 大多数其他开发人员已经使用Eclipse设置了他们的构建,但我正在尝试通过现有的build.xml文件来构建它。

After getting my classpath set, the build runs smoothly, but shortly after starting the compile step, it returns: 获取我的类路径后,构建运行顺利,但在开始编译步骤后不久,它返回:

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

This is less than helpful. 这不是很有用。 The build.log has no additional information other than the stack trace: 除了堆栈跟踪之外,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) 

Adding the -debug flag to ant creates mountains of information, and with such a long classpath (so many jars) it is hard to sort through it. -debug标志添加到ant会创建大量信息,并且使用如此长的类路径(如此多的罐子),很难对其进行排序。

Here's the target in 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> 

The classpath is set through that classpathref and has a lot of jars included through and tags. 类路径是通过classpathref设置的,并且通过和标签包含了很多jar。

Any thoughts on what I should be lookinf for? 关于我应该看什么的任何想法? What would cause ant to fail like this? 会导致蚂蚁失败的原因是什么?

CLASSPATH should be set inside the build.xml itself. 应该在build.xml本身内部设置CLASSPATH。 If you're depending on a CLASSPATH environment variable, you're making a mistake. 如果你依赖于CLASSPATH环境变量,那你就犯了一个错误。

See if this build.xml works better. 看看这个build.xml是否更好。 Study the directory structure and make yours match that spelled out in the 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>

Can you run your ant build in debug mode so that you can step through it? 你可以在调试模式下运行你的ant构建,以便你可以单步执行它吗? Set a break point in your build.xml. 在build.xml中设置断点。 Then Right click on the build.xml and select Debug As -> Ant Build (assuming you are using Eclipse). 然后右键单击build.xml并选择Debug As - > Ant Build(假设您正在使用Eclipse)。 This might help you to figure out your issue. 这可能有助于您找出问题所在。

HTH. HTH。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM