hi. i just downloaded ant a couple of days ago. i quite like it!
i have a number of projects that follow a pretty well-defined paradigm, so
i'm using a template.xml file to "factor out" commonalities in the project
build.xml files. i essentially "include" this template using the <ant> task
(see example below).
this is a little redundant (a target like [template/init] is entered twice)
and a bit awkward. could it be worth considering a tag called <include>,
under <project> and parallel with <target>? it could be placed above all of
the <target>s for a given project and would effectively "include" all of the
targets in the included .xml file.
currently, my template looks something like:
<project name="template" default="compile" basedir="/development">
<target name="init">
<tstamp/>
<property name="sources" value="${basedir}/sources"/>
<property name="builds" value="${basedir}/builds"/>
<property name="distributions" value="${basedir}/distributions"/>
<property name="distjardir" value="${basedir}/temp/distjar"/>
<property name="jarexclude" value="**/*.properties,**/*.policy"/>
<property name="rootdistdir"
value="${distributions}/${project}${version}"/>
<property name="distdir"
value="${distributions}/${project}${version}/${project}"/>
<property name="docdir" value="${distdir}/${project}/doc"/>
</target>
<target name="compile" depends="init">
<mkdir dir="${builds}"/>
<javac srcdir="${sources}" destdir="${builds}"
includes="${project}/**" excludes="${project}/*.xml"/>
</target>
<target name="dist" depends="compile">
<mkdir dir="${distjardir}"/>
<copydir src="${builds}" dest="${distjardir}" includes="${project}/**"/>
<mkdir dir="${distdir}"/>
<jar jarfile="${distdir}/${project}.jar" basedir="${distjardir}"
excludes="${jarexclude}"/>
<copydir src="${distjardir}" dest="${rootdistdir}"
includes="${jarexclude}"/>
</target>
<target name="doc" depends="init">
<mkdir dir="${docdir}"/>
<javadoc sourcepath="${sources}" destdir="${docdir}"
packagenames="${project}.*"/>
</target>
<target name="clean" depends="init">
<deltree dir="${builds}/${project}" />
<deltree dir="${distjardir}" />
<deltree dir="${rootdistdir}" />
</target>
</project>
------------------------------------------------
then project build.xml's look something like:
------------------------------------------------
<project name="adapted" default="dist" basedir="/development">
<target name="init">
<property name="project" value="adapted"/>
<property name="version" value="1.0"/>
<deltree dir="${basedir}/temp"/>
</target>
<target name="compile" depends="init">
<ant antfile="${basedir}/template.xml" dir="${basedir}"
target="compile"/>
</target>
<target name="dist" depends="compile">
<ant antfile="${basedir}/template.xml" dir="${basedir}" target="dist"/>
</target>
<target name="doc" depends="compile">
<ant antfile="${basedir}/template.xml" dir="${basedir}" target="doc"/>
</target>
<target name="clean" depends="init">
<ant antfile="${basedir}/template.xml" dir="${basedir}" target="clean"/>
</target>
</project>
------------------------------------------------
------------------------------------------------
<project name="jmc" default="dist" basedir="/development">
<target name="init">
<property name="project" value="jmc"/>
<property name="version" value="1.0"/>
<property name="builds" value="${basedir}/builds"/>
<deltree dir="${basedir}/temp"/>
</target>
...
<target name="rmic" depends="compile">
<rmic base="${builds}" classname="${project}.db.remote.DBI"/>
</target>
<target name="dist" depends="rmic">
<ant antfile="${basedir}/template.xml" dir="${basedir}" target="dist"/>
</target>
...
</project>