9. Tag javac <javac srcdir= "${src}" destdir= "${build}" /> Il tag javac è usato per compilare una o più classi: Anche con svariati attributi di compilazione: <javac sourcepath= "" srcdir= "${src}" destdir= "${build}" > <include name= "**/*.java" /> <exclude name= "**/Example.java" /> </javac>
10. Tag property the url from which to read properties. <property url="http://www.mysite.com/bla/foo.properties"/> url the filename of the property file. <property file="ant-global.properties"/> <property file="${user.home}/ant-global.properties"/> file the resource name of the property file. <property resource="foo.properties"/> resource Sets the property to the absolute filename of the given file. <property name="src" location="src"/> location the value of the property. <property name="compile" value="2"/> value the name of the property to set. <property name="src" … name Description Attribute
11. Un semplice buildfile <project name= "MyProject" default= "dist" basedir= "." > <description> simple example build file </description> <!-- set global properties for this build --> <property name= "src" location= "src" /> <property name= "build" location= "build" /> <property name= "dist" location= "dist" /> <target name= "init" > <!-- Create the time stamp --> <tstamp/> <!-- Create the build directory structure --> <mkdir dir= "${build}" /> </target>
12. Un semplice buildfile <target name= "compile" depends= "init" description= "compile" > <!-- Compile the java code from ${src} into ${build} --> <javac srcdir= "${src}" destdir= "${build}" /> </target> <target name= "dist" depends= "compile" description= "generate the distribution" > <!-- Create the distribution directory --> <mkdir dir= "${dist}/lib" /> <!– put ${build}into the MyProject-${DSTAMP}.jar file --> <jar jarfile= "${dist}/lib/MyProject-${DSTAMP}.jar" basedir= "${build}" /> </target>
13. Un semplice buildfile <target name= "clean" description= "clean up" > <!-- Delete the ${build} and ${dist} directory --> <delete dir= "${build}" /> <delete dir= "${dist}" /> </target> </project>
14.
15. Esempio buildfile con più target <?xml version="1.0" encoding="UTF-8"?> <project name= "EJB Mail BottegaVerde Project" default= "ejb-jar" basedir= "." > <target name= "init" > <!-- Project Directories --> <property name= "src.dir" value= "${basedir}/ejbModule" /> <property name= "classes.dir" value= "${basedir}/classes" /> <property name= "resources.dir" value= "${basedir}/resources" /> <!-- Archive names --> <property name= "archive.name" value= "bottegaVerdeMail" /> <!-- Sets the jboss directory from the local environment --> <property environment= "env" /> <!-- Override with your JBoss server dist location if JBOSS_DIST is not set --> <property name= "jboss.dist" value= "${env.JBOSS_DIST}" /> </target> <target name= "compile" depends= "init" > <mkdir dir= "${classes.dir}" /> <javac srcdir= "${src.dir}" destdir= "${classes.dir}" debug= "on" deprecation= "on" optimize= "off" > <classpath> <fileset dir= "${jboss.dist}/client" includes= "**/*.jar" /> </classpath> </javac> </target>