Since Ant is an Open source software, there are two ways to install Ant, one is to install Ant with a compiled binary file, and the other is the source code you build Ant.
The binary form in the form of Ant can be downloaded from http://jakarta.apache.org/builds/ant/release/v1.4.1/bin. If you want you to compile Ant, you can get from http://jakarta.apache.org/builds/ant/release/v1.4.1/src. Note that the listed connections are the latest release of Ant. If you read this article, found that there is already an updated version, then use the new version. If you are a crazy technical pursuit, you can also download the latest version from Ant CVS Repository.
system requirement
Want to think about Build Ant. You need a JAXP-compatible XML parser (PARSER) in your ClassPath system variable.
The binary form of Ant includes the latest version of the Apache Crimson XML parser. You can get more information about JAXP from http://java.sun.com/xml/. If you want to use other JAXP compatible parsers. You have to delete JAXP. JAR and CRIMSON.jar from the LIB directory of Ant. Then you can put your loved parser JAR file in the Ant's lib directory or put it in your ClassPath system variable.
For the current version of Ant, you need JDK, 1.1 or higher in your system. The future Ant version will require JDK 1.2 or higher.
Install ANT
Binary version of Ant includes three directories: BIN, DOCS and LIB. Only the bin and lib directory are required to run Ant. To install Ant, select a directory and copy the release of the release to this directory. This directory is called Ant_Home.
Do some configuration work before you run Ant.
Add a bin directory to the PATH environment variable.
Set the ANT_HOME environment variable to point to the directory where you install Ant. On some OS, Ant's script can guess Ant_Home (UNIX and WindOS NT / 2000) - but it is best not to rely on this feature.
Alternatively, the Java_Home environment variable (refer to the following advanced section), which should point to the directory of the JDK installed.
Note: Do not put the Ant.jar files of the Ant to the lib / ext directory of JDK / JRE. Ant is an application, and the lib / EXT directory is used for JDK extension (such as JCE, JSSE extension). And there will be security restrictions by extension.
Optional Task
Ant supports some optional TASK. An optional Task generally requires an additional library to work. Optional Task is separated from the built-in Task of Ant, packaged separately. This optional package can be downloaded from the same place you download from Ant. The JAR file name called optional Task is called Jakarta-Ant-1.4.1-optional.jar. This JAR file should be placed in the lib directory of the Ant installation directory.
The external library required for each optional Task can be referring to the dependent library section. These external libraries can be placed in the LIB directory of Ant, so Ant can be automatically loaded, or put it in an environment variable.
Windows
Assume that Ant is installed in a C: / Ant / directory. Below is a command to set the environment:
SET ANT_HOME = C: / Ant
SET JAVA_HOME = C: /JDK1.2.2
SET PATH =% PATH%;% Ant_Home% / BIN
UNIX (Bash)
Assume that Ant is installed in the / usr / local / Ant directory. Below is a command to set the environment:
Export Ant_Home = / usr / local / Ant
Export java_home = / usr / local / JDK-1.2.2Export path = $ {pat}: $ {ant_home} / bin
advanced
To run Ant, you must use a lot of variables. You need at least reference to the following:
Ant's classpath must contain Ant.jar and the JAR file that you choose JAXP-compatible XML parser.
When you need JDK's function (such as Javac or RMIC Task), for JDK 1.1, JDK's classs.zip file must be placed in ClassPath; for JDK 1.2 or JDK 1.3, you must join Tools.jar. If the correct Java_Home environment variable is set, the script belongs in Ant, in the bin directory, automatically add the desired JDK class.
When you perform a specific platform program (such as Exec Task or CVS Task), you must set the Ant.home property to point to the installation directory of Ant. Similarly, the scripts belled by the ANT use the ANT_HOME environment variable to automatically set this property.
Running Ant is very simple, when you correctly install Ant, just enter Ant.
When you do not specify any parameters, Ant will query the build.xml file in the current directory. If you find it, use this file as buildfile. If you use the -find option. Ant will look for BuildFile in the superiors until the root of the file system is reached. To allow Ant to use other buildfiles, you can use the parameter -Buildfile file, where the file specifies the buildfile you want to use.
You can also set some properties to override the property value specified in the buildfile (see Property Task). You can use the -Dproperty = value option, where Property is the name of the attribute, and the value is the value of the attribute. This approach can also be used to specify the value of some environment variables. You can also use Property Task to access environment variables. Just pass -dmyvar =% myvar% (Windows) or -dmyvar = $ myvar (unix) to Ant - you can access these environment variables with $ {myvar} in your buildfile.
There are two option -quite, telling Ant run only a small amount of necessary information. And -verbose tells Ant to output more information.
You can specify one or more Targets. When Target is omitted, the ANT uses the target attribute specified by the Default property of the label
If there is, the -projecthelp option outputs a list of description information and item Target. The Targets that are described and then described are not described.
Command line option summary:
Ant [options] [target [target2 [target3] ...]]]]]]]
Options:
-Help Print this Message
-ProjectHelp Print Project Help Information
-version print the version information and exit
-quiet be extra quiet
-verbose be extra verbose
-debug print debugging information
-emacs produpe logging information without adornments
-logfile file use Given File for log output
-logger classname the class thing is to perform logging-listener classname add an instance of class as a project listener
-Buildfile File Use Specified BuildFile
-find file search for buildfile touth the root of the filesystem and use the first one found
-Dproperty = Value Set Property to Value
example
Ant
Use the build.xml in the current directory to run Ant, perform the default target.
Ant -buildfile Test.xml
Use the Test.xml in the current directory to run Ant, perform the default target.
Ant -Buildfile Test.xml Dist
Use the Test.xml under the current directory to run Ant, perform a target called DIST.
ANT -BUILDFILE TEST.XML -DBUILD = Build / Classes Dist
Use the Test.xml in the current directory to run Ant, perform a target called Dist, and set the value of the build property of the build / class.