![]() |
![]() |
![]() |
![]() |
||||
|
|||||
What is 'ant'?Ant is a build utility written in Java and primarily for Java programs. It is often described as "something like The build script is written as an XML document that expresses the dependencies between various subcomponents or tasks (called targets) of a project For example, the most basic task when building a Java project is compiling the source code.
You therefore write a target definition that includes the javac task, which performs the compilation. Then, at the command line, you type The next target you will need is one to execute the program. You cannot execute the program without it first having been compiled, so the execution target depends on the compilation target. Before long, you find yourself writing targets to clean up directories of compiled code, jar up class files, auto-deploy to particular directories or applications, run unit tests, interact with source-code control systems such as CVS, and so on. There are very many target types supported, and if what you want to do is not already supported, you can always extend ant by writing your own target (its not difficult). In effect, the ant script becomes a central point of contact between you and any management tasks for your project. For example, here is a simple "baseline" ant script: <project name="MyProject" default="dist" basedir="."> <!-- set global properties for this build --> <property name="src" location="src"/> <property name="build" location="build"/> <path id="main.classpath"> <pathelement location="${build}"/> <pathelement location="other.jar"/> </path> <target name="init"> <!-- Create the time stamp --> <tstamp/> <!-- Create the build directory structure used by compile --> <mkdir dir="${build}"/> </target> <target name="compile" depends="init" description="compile the source " > <javac srcdir="${src}" destdir="${build}"/> </target> <target name="run" depends="compile" description="executes the program"> <java classname="com.something.MyClass" classpathref="main.classpath" fork="yes"/> </target> </project> For more information, visit the Apache Ant Project web site at ant.apache.org Other Terms |