<?xml version="1.0" ?>
<project name="secondbuildJAR" default="compile">
<property file="${user.home}/build.properties"/>
<property name="source.dir" location="src"/>
<property name="build.dir" location="build"/>
<property name="build.classes.dir" location="${build.dir}/classes"/>
<property name="distribution.dir" location="dist"/>
<property name="distribution.doc.dir" location="${distribution.dir}/doc" />
<property name="project.name" value="${ant.project.name}" />
<property name="project.version" value="0.1.alpha" />
<property name="target.name" value="${project.name}-${project.version}.jar" />
<property name="target.jar" location="${distribution.dir}/${target.name}" />
<patternset id="meta.files">
<include name="**/*.xml"/>
<include name="**/*.properties"/>
</patternset>
<path id="compile.classpath">
<fileset dir="lib">
<include name="*.jar"/>
<include name="*.zip"/>
</fileset>
</path>
<path id="run.classpath">
<path refid="compile.classpath"/>
<pathelement location="${target.jar}"/>
</path>
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${distribution.dir}" /> <!--this will delete both dist and dist/doc -->
<mkdir dir="${build.classes.dir}" />
<mkdir dir="${distribution.doc.dir}" />
</target>
<!-- Copy metadata to build classpath -->
<target name="copymetafiles" depends="clean">
<copy todir="${build.classes.dir}">
<fileset dir="${source.dir}">
<patternset refid="meta.files"/>
</fileset>
</copy>
</target>
<target name="compile" depends="copymetafiles" description="Compiles the project">
<javac srcdir="${source.dir}"
destdir="${build.classes.dir}"
debug="${build.debug}">
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="archive" depends="compile" description="JARs up the project">
<jar destfile="${target.jar}"
duplicate="preserve"
manifest="${source.dir}/META-INF/MANIFEST.MF">
<fileset dir="${build.classes.dir}"/>
</jar>
</target>
<target name="execute" depends="archive" description="Executes the main class">
<echo>running this program now!!!</echo>
<java classname="org.antbook.welcome.Main" classpathref="run.classpath" failonerror="true">
<arg value="a" />
<arg value="b" />
<arg file="." />
</java>
<echo>end running the program!!!</echo>
</target>
<target name="echo">
<echo message="ant.file = ${ant.file}" /><!--where this ant file is located-->
<echo message="ant.home = ${ant.home}" />
<echo>ant.version = ${ant.version}</echo>
<echo>java.home = ${java.home}</echo>
<echo message="ant.java.version = ${ant.java.version}" />
<echo>ant.project.name = ${ant.project.name}</echo>
<echo>user.name = ${user.name}</echo>
<echo>user.home = ${user.home}</echo>
<echo>basedir = ${basedir}</echo>
<echo>build.debug = ${build.debug}</echo>
</target>
</project>
Sunday, February 03, 2008
java: A simple ANT template
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment