I am new to Ant build script. I am trying to do following things
- Delete the build directory
- Create the build directory
- Compile the code
- Create jar file for each package in the project
for this I have written following code
<?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>
When I execute the ant script on command line with verbose option it gives me following output
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
I even tried debugging the script in eclipse. The debug point was set at the “prepare” target and when we press F5 it exits the debugging. It does not show any error message.
Can anyone let me know what is wrong in the script?
You didn’t tell Ant which target to run. Either specify
-p(or select a target to run in the Eclipse Ant runner) or define a default target to run in the<project>tag.