ant build脚本不能使用命令行在Windows上运行

时间:2012-08-30 04:59:32

标签: ant build

我编写了一个ant脚本,运行正常并在我使用eclipse时生成.jar文件。 但是当我在Windows XP上的命令提示符下使用它时,它显示成功,但没有任何反应。 ant已正确配置,我也可以运行其他ant脚本。

这是我的build.xml文件

<?xml version="1.0"?>
<project name="TaskNodeBundle" basedir=".">
    <!-- Sets variables which can later be used. -->
    <!-- The value of a property is accessed via ${} -->
    <property name="bundlename" value="task-node-bundle" />
    <property name="src.dir" location="../src" />
    <property name="lib.dir" location="../lib" />
    <property name="build.dir" location="/buildoutput" />
    <property name="build.dest" location="build/dest" />


    <!--
    Create a classpath container which can be later used in the ant task
  -->
    <path id="classpath">
        <fileset dir="${lib.dir}/">
            <include name="*.jar" />

        </fileset>
    </path>

    <target name="clean">
            <delete dir="${build.dir}" />
            <delete dir="${build.dest}" />
    </target>


    <!-- Deletes the existing build directory-->
    <target name="mkdir" depends="clean">
            <mkdir dir="${build.dest}"/>
    </target>


<!-- Compiles the java code -->
    <target name="compile" depends="mkdir">
        <javac srcdir="${src.dir}" destdir="${build.dest}" classpathref="classpath" />
    </target>

    <target name="package-bundle" depends="compile" description="Generates the bundle">
        <jar destfile="${dist.dir}/${bundlename}.jar">
            <fileset dir="${src.dir}">
                <include name="**/**.class" />
                <include name="**/**.properties"/>
                <include name="/META-INF/**.*" />
                <include name="/META-INF/spring/**.*" />
            </fileset>

        </jar>
    </target>


</project>

1 个答案:

答案 0 :(得分:3)

当您从命令行执行ant脚本时,它将执行build.xml文件中定义的第一个目标(在您的情况下为clean)。

您可以在命令行中指定要执行的目标

$ ant target1 target2

或使用<project>标记的默认属性在build.xml文件中定义默认目标:

<project name="TaskNodeBundle" basedir="." default="package-bundle">