Shown
next is a generic buildfile good for using as a template. A buildfile
consists of the <project>
element with its
nested <target>
,
<property>
, and
<path>
elements.
<project default="all"> <property name="a.property" value="a value"/> <property name="b.property" value="b value"/> <path id="a.path"> <pathelement location="${java.home}/jre/lib/rt.jar"/> </path> <target name="all"> <javac srcdir="."> <classpath refid="a.path"/> </javac> </target> </project>
Some notes about buildfiles to remember:
All buildfiles require the
<project>
element and at least one<target>
element.There is no default value for the
<project>
element’sdefault
attribute.Buildfiles do not have to be named
build.xml
. However,build.xml
is the default name for which Ant searches.You can have only one
<project>
element per buildfile.
Get Ant: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.