繁体   English   中英

通过build.xml构建目标时出错

[英]Error with target in building by build.xml

我打开了一个在eclipse env中包含build.xml和ivy.xml的项目。 在我应用运行方式..>通过右键单击build.xml生成的Ant Ant之后,我遇到了此错误:

    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>

在此部分中发生错误:

在此处输入图片说明

我将其更改为

<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 env中没有任何ant插件等),如果有,我应该在eclipse中使用哪个插件才能正确打开此类项目?

请帮我。 谢谢

错误在这里:

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

声明目标名称为“ retrieve”或删除依赖项。

这是通过从另一个构建文件中复制粘贴粘贴创建的构建文件吗?

首要问题

您有一个编译目标,该目标依赖于另一个不存在的目标,称为“检索”

 <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>

使用ivy时,通常有一个首先解决(如果需要的话可以下载)第3方j​​ar依赖项的目标。 为了编译代码,这是必需的。

第二期

您的第二个错误是由您的构建的以下部分引发的:

<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} / default目录中找到jar。 大概这是丢失检索任务的一部分。

使用常春藤的工作示例

希望这可以帮助。

转到首选项,选中“忽略所有buildfile问题”。

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

暂无
暂无

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

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