Ant在错误的目标中创建jar文件

时间:2016-08-03 06:37:10

标签: ant

下面是我的ant。

的build.xml文件
<?xml version="1.0" encoding="UTF-8"?>

<project name="Struts2ProductsDemo" default="jar">
    <property name="src.dir" location="src" />
    <property name="build.dir" location="L:\build" />
    <property name="project.name" value="Struts2ProductsDemo" />

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

<target name="makedir">
    <mkdir dir="${build.dir}" />
    <mkdir dir="${build.dir}/classes" />
</target>

<target name="compile" depends="clean,makedir">
    <javac srcdir="${src.dir}" destdir="${build.dir}/classes" />
</target>

<target name="jar" depends="compile">

    <jar destfile="${build.jar}/jars/${project.name}.jar" basedir="${build.dir}/classes" />
</target>

jar文件创建于:C:\Users\San\EclipseWS\Struts2ProductsDemo\${build.jar}\jars\Struts2ProductsDemo.jar

我期待jar在这里:${build.jar}/jars/${project.name}.jar

1 个答案:

答案 0 :(得分:0)

永远不会设置属性build.jar。你必须定义它。例如,您可以将其添加到您的构建中:

<property name="build.jar" location="target"/>