我是Ant构建脚本的新手。我正在尝试做以下事情
为此我写了以下代码
<?xml version="1.0"?>
<project name="test" basedir=".">
<property name="build.lib" value="dist"/>
<property name="prefix" value="XXX"/>
<property name="src.dir" value="src"/>
<property name="build.dir" value="build"/>
<property name="build.classes" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>
<path id="compile.classpath">
<fileset dir="OpenJPA_lib_jar">
<include name="*.jar"/>
</fileset>
</path>
<macrodef name="build_jar">
<attribute name="name"/>
<sequential>
<jar destfile="${build.lib}/${prefix}-@{name}.jar">
<fileset dir="${build.classes}">
<include name="zumigo/geofence/@{name}/**"/>
</fileset>
</jar>
</sequential>
</macrodef>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<echo message="Build dir = ${build.dir}"/>
<target name="prepare">
<mkdir dir="${build.dir}"/>
</target>
<target name="compile" depends="prepare">
<javac destdir="${build.classes}" debug="true" srcdir="${src.dir}">
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="run" depends="compile">
<build_jar name="common"/>
<build_jar name="dal"/>
<build_jar name="databeans"/>
<build_jar name="dataobject"/>
<build_jar name="dto"/>
<build_jar name="exception"/>
</target>
</project>
当我在命令行上使用verbose选项执行ant脚本时,它会给出以下输出
Apache Ant(TM) version 1.8.3 compiled on February 26 2012
Trying the default build file: build.xml
Buildfile: E:\XXX\XXXWorkspaces\GeoFence\v1.0\GeoFence_Java\build.xml
Detected Java version: 1.6 in: C:\Program Files\Java\jdk1.6.0_14\jre
Detected OS: Windows XP
parsing buildfile E:\XXX\XXXWorkspaces\GeoFence\v1.0\GeoFence_Java\build.xml with URI = file:/E:/XXX/XXXWorkspaces/GeoFence/v1.0/GeoFence_Java/build.xml
Project base dir set to: E:\XXX\XXXWorkspaces\GeoFence\v1.0\GeoFence_Java
parsing buildfile jar:file:/D:/Downloads/apache-ant-1.8.3/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/D:/Downloads/apache-ant-1.8.3/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
[macrodef] creating macro build_jar
[echo] Build dir = build
BUILD SUCCESSFUL
Total time: 0 seconds
我甚至尝试在eclipse中调试脚本。调试点设置在“准备”目标,当我们按F5它退出调试。它不显示任何错误消息。
任何人都可以让我知道脚本中有什么问题吗?
答案 0 :(得分:2)
你没有告诉Ant要运行哪个目标。指定-p
(或选择要在Eclipse Ant运行程序中运行的目标)或定义要在<project>
标记中运行的默认目标。