From 559859ef43a7d03b5f17ff1121f9d3e7a5c79656 Mon Sep 17 00:00:00 2001
From: Conor MacNeill Version 1.0.8.1 - 2000/06/13 Version 1.0.8.1 - 2000/06/27 Ant is a Java based build tool. In theory it is kind of like make without
@@ -68,6 +72,7 @@ gives you the ability to be cross platform. To work anywhere and everywhere. And
hey, if you really need to execute a shell command, Ant has an exec rule that
allows different commands to be executed based on the OS that it is executing
on.
Table of Contents
+
Introduction
Getting Ant
Binary edition
@@ -82,14 +87,20 @@ href="http://jakarta.apache.org/builds/tomcat/release/v3.0/src/jakarta-tools.src
href="http://jakarta.apache.org/from-cvs/jakarta-tools/">http://jakarta.apache.org/from-cvs/jakarta-ant/
(current). See the section Building Ant on how to
build Ant from the source code.
- Download and install the Java API for XML Parsing kit from - http://java.sun.com/xml. - Make sure the "jaxp.jar" and "parser.jar" files are in your class - path. -
+ To build and use ant you must have a JAXP compilant XML parser installed and available on your classpath. ++ If you do not have a JAXP compliant XML parse installed, you may use the reference implementation + available from Sun. It is available from http://java.sun.com/xml. + Once installed make sure the "jaxp.jar" and "parser.jar" files are in your classpath. +
+ You will also need the JDK installed on your system, version 1.1 or later. + +
Go to the directory jakarta-ant
.
Make sure the JDK is in you path.
Run bootstrap.bat
(Windows) or bootstrap.sh
(UNIX)
@@ -131,11 +142,13 @@ export PATH=${PATH}:${ANT_HOME}/bin
There are lots of variants that can be used to run Ant. What you need is at least the following:
-The classpath for Ant must contain ant.jar
and xml.jar
.
The classpath for Ant must contain ant.jar
and any jars/classes
+needed for your chosen JAXP compliant XML parser.
When you need JDK functionality (like a javac task, or a
rmic task), then for JDK 1.1, the classes.zip
file of the JDK must be added to the classpath; for JDK 1.2, tools.jar
-must be added.
tools.jar
automatically if the JAVA_HOME environment variable is set.
When you are executing platform specific applications (like the exec task, or the cvs task), the property ant.home
must be set to the directory containing a bin directory, which contains the antRun
shell script necessary to run execs on Unix.
ant [options] [target] Options: -help print this message +-version print the version information and exit -quiet be extra quiet -verbose be extra verbose -logfile <file> use given file for log +-listener <classname> add an instance of class as a project listener -buildfile <file> use given buildfile -D<property>=<value> use value for given property
When you have installed Ant in the do-it-yourself way, Ant can be started with:
-+set CLASSPATH=c:\ant\lib\ant.jar;c:\ant\lib\xml.jar;c:\jdk1.2.2\lib\tools.jar -java -Dant.home=c:\ant org.apache.tools.ant.Main [options] [target]+java -Dant.home=c:\ant org.apache.tools.ant.Main [options] [target]
These instructions actually do exactly the same as the ant
command. The options and target are the same as when running Ant with the ant
-command.
The buildfile is written in XML. Each buildfile contains one project.
@@ -359,13 +379,14 @@ this should not cause problems. </project> +Some tasks use directory trees for the task they perform. For instance, the Javac task which works upon a directory tree with .java files. Sometimes it can be very useful to work on a subset of that directory tree. This section describes how you can select a subset of such a directory tree.
-Ant gives you two ways to create a subset, which both can be used at the same +
Ant gives you two ways to create a subset, both of which can be used at the same time:
This copies all files in directories called "images", that are located in the directory tree "${src}" to the destination "${dist}", but excludes all "*.gif" files from the copy.
+This example can also be expressed using nested elements as +
<copydir src="${src}" + dest="${dist}"> + <include name="**/images/*"/> + <exclude name="**/*.gif" /> + </copydir> ++
There are a set of definitions which are excluded by default from all directory based tasks. They are: @@ -2161,7 +2190,8 @@ implementations may use other values for the home directory on Windows.
Replaces the occurrence of a given string with another string in a file.
+Replace is a directory based task for replacing the occurrence of a given string with another string +in selected file.
file | -file for which the token should be replaced. | -Yes | +file for which the token should be replaced. If not present the dir attribute + must be specified | +No | +
dir | +The base directory to use when replacing a token in multiple files. If not present the file attribute + must be specified | +No | ||
token | @@ -2185,6 +2222,36 @@ implementations may use other values for the home directory on Windows. ("") is used.No | |||
includes | +comma separated list of patterns of files that must be + included. All files are included when omitted. | +No | +||
includesfile | +the name of a file. Each line of this file is + taken to be an include pattern | +No | +||
excludes | +comma separated list of patterns of files that must be + excluded. No files (except default excludes) are excluded when omitted. | +No | +||
excludesfile | +the name of a file. Each line of this file is + taken to be an exclude pattern | +No | +||
defaultexcludes | +indicates whether default excludes should be used or not + ("yes"/"no"). Default excludes are used when omitted. | +No | +
<replace file="${src}/index.html" token="@@@" value="wombat" />@@ -2629,6 +2696,36 @@ in the
${dist}
directory.
zips all files in the htdocs/manual
directory in a file called manual.zip
in the ${dist}
directory. Files/directories with the names mydocs
and todo.html
are excluded.
To use build events you need to create an ant Project
object. You can then call the
+addBuildListener
method to add your listener to the project. Your listener must implement
+the org.apache.tools.antBuildListener
interface. The listener will receive BuildEvents
+for the following events
+
++will run ant with a listener which generates an XML representaion of the build progress. This +listener is included with ant as is the default listener which generates the logging to standard +output. + +ant -listener org.apache.tools.ant.XmlLogger+
It is very easy to write your own task: