80 likes | 206 Vues
Discover Apache Ant, an open-source build automation tool used for Java projects and OS-independent tasks. This guide covers its XML-based configuration, core functionalities, and sample build files. Learn about targets, tasks, and properties with practical examples, including how to set up a basic build.xml. With Apache Ant, you can easily manage your projects' build processes, enabling efficient compilation, copying, and documentation generation. Get started with the necessary requirements and unleash the power of custom tasks for your development.
E N D
< ant > nrg
Open source from Jakarta. • Build tools make, gnumake, nmake. • Implemented in Java, and O.S. independent • Configuration files are XML based. • REQUIREMENTS JAXP Parser ( xercers.jar ) JDK 1.2 or higher ANT_PATH
Every project using ant has a default build.xml • Inside build.xml -- Each build file contains one project and a default target ex: Compile is a target -- targets contain task elements ex: Tasks for compile, are copy, compile, delete -- tasks have values assigned to attributes
Project: example 3 < Javadoc > tasks targets javadoc 2 < javac > < copy > compile 1 init < makedir >
SAMPLE BUILD FILE <?xml version="1.0"?> <project name="example" default ="javadoc" basedir="."> <property name="name" value="example" /> <property name="source" value="source" /> <property name="build" value="${basedir}/build" /> <property name="docDir" value="doc" /> <target name= "init" > <mkdir dir="${build}" /> <mkdir dir="${source}" /> <mkdir dir="${docDir}" /> </target>
<target name="copy"> <copy todir="${source}"> <fileset dir="${basedir}" includes="*.java"/> </copy> </target> <target name="compile" depends="init,copy" > <javac srcdir="${source}" destdir="${build}" > </javac> </target> <target name="javadoc" depends ="compile"> <javadoc sourcepath="${source}" packagenames="Adder.*" destdir="${docDir}" /> </target> </project>
Output indicates the tasks that are executed like init, copy, compile • Can build your own tasks org.apache.tools.ant.Task • Gui version of ant is still under development