What is 1.ant?
Apache Ant is a Java-based build tool, in theory, it is a bit like Make, but there is no Make's defect.
Why is Make, Gnumake, Make, Jam and other build tools, and a new build tool? Because the original author of Ant cannot endure the limitations and inconveniences caused by these tools in cross-platform development. Tools similar to Make is based on the shell: they calculate the dependencies and then execute the command. These commands don't have much difference with the command you execute under the command line. This means you can easily use your operating system writing programs to extend the tool; this also means that you will limit yourself on a specific operating system, at least on the type of operating system, such as UNIX.
Makefiles is also very disgustable. Anyone who has used their people have encountered a variable Tab problem. "My command can't be executed, is it just because my TAB has a space in front?" The author of Ant said this sentence many times. Some tools such as JAM can deal with such issues well, but users must use and remember another new format.
Ant is different. Unlike the extended mode based on the shell command, ANT expands with Java classes. (User) Do not have to write the shell command, the configuration file is based on XML, and various TASK can be performed by calling the Target tree. Each Task is run by an Object (object) that implements a specific Task Interface. (If you have no words to Ant, you may not understand this section, there is no relationship, you will introduce the Target, Task. You can even skip this section without too much time, then then When I came back, I would understand it here. Similarly, if you are not familiar with the tools such as Make, the following introduction will not use the concept in Make.)
It must be admitted that this will lose some unique expressive capabilities when constructing the shell command. Such as `find. -Name foo -exec rm {}`, but gives you a cross-platform ability - you can work anywhere. If you really need to perform some shell commands, Ant has a
2. Install ANT
2.1 get an Ant
Binary version (binary edition)
On the Web page http://ant.apache.org/ You can get the latest stable version of the ANT. If you are crazy technology pursuit (Living on the Edge), you can download to the latest version from http://cvs.apache.org/builds/ant/nightly/
Source Edition (Source Edition)
If you prefer a source version, you can download it from http://ant.apache.org/srcdownload.cgi to the latest version of the source code. Similarly, if you are crazy technology pursuit, you can get these code in development via CVS. There is a detailed information on accessing CVS on the Jakarta website. Please Checkout Ant module. Read the Build Ant section About how to build Ant using the source code, you can also access Ant CVS Repository online.
2.2 System Needs
Ant can be used on a variety of platforms, including Linux, Commercial UNIX, Windows 9X and NT, OS / 2 Warp, Novell NetWare 6, and Macos X. To build and use Ant, you must have a JAXP-compatible XML parser in your ClassPath path.
Binary forms of Ant include the latest version of the Apache Xerces2 XML parser. Please consult http://java.sun.com/xml/ to get more detailed information about JAXP. If you want to use a different JAXP-compatible XML parser, you need to remove XerceptImpl.jar and XML-Apis.jar from the Lib Directory of Ant. Then you can put the JAXP-compatible XML parser you want to use in the Lib Directory of the Ant, or you can add JAR path to the system's classpath variable.
For the current version of Ant, you need to install a 1.2 or higher JDK.
Note: Microsoft (Microsoft) JVM / JDK is not supported.
Note 2: If only the JRE running environment without JDK, it will cause many TASKs that cannot be executed.
2.3 Installing Ant
The directory structure of a binary form is as follows: Ant --- bin // contains run scripts | --- lib // contains Ant necessary JAR files | --- DOCS // contains documents | --- Antchist | | | | - images // HTML document for logos | | | --- manual // Ant documentation | --- etc // contains XSL file:
Only bin directory and lib directory are required to run Ant. Select a directory and copy the ANT to the directory, you can complete the installation of Ant, which will be identified by Ant_Home.
Windows 95, Windows 98 & Windows ME Note: Under these systems, if Ant_home has a long file name (such as the file name is not recognized "8.3" 8.3 "), the script running Ant may return a problem. This is caused by the restriction of the "for" batch file command by the operating system. It is recommended to use short file names, such as C: / Ant. Under these systems, you also need to configure more environmentally space to engage in the use of environment variables of Ant run scripts. In order to achieve this, you must add or correct below in config.sys: shell = c: /command.com C: / / p / E: 32768
Set
There are some additional required settings before you can run Ant.
• Add the path to the bin directory in the PATH variable. · Set the ANT_HOME environment variable, the value of the value of Ant is the installation path. On some operating systems, the ANT package script can speculate ant_home (UNIX Dialects and Windows NT / 2000). But it is best not to rely on these features. · Optional, set the Java_Home environment variable (see the Advanced section behind). This must point to the JDK installation directory.
Note: Don't put the Ant's Ant.jar files in 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. These optional Task and Core Ant Tasks are packaged together. The external library required for each optional Task can refer to the Library DependenCIES 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 and OS / 2
Suppose Ant is installed in C: / Ant /. Use the following command to set the environment variable.
SET ANT_HOME = C: / ANTSET JAVA_HOME = C: /JDK1.2.2Set Path =% PATH%;% Ant_Home% / Bin
UNIX (Bash)
Suppose Ant is installed in / usr / local / Ant. Use the following command to set the environment variable.
Export Ant_Home = / usr / local / antient java_home = / usr / local / jdk-1.2.2export path = $ {pat}: $ {ant_home} / bin
UNIX (CSH)
Suppose Ant is installed in / usr / local / Ant. Use the following command to set the environment variable.
SetENV ANT_HOME / USR / local / antstenv java_home /usr/local/jdk-1.2.2set path = ($ PATH $ ANT_HOME / BIN)
advanced
Running Ant to use a lot of variables, you need at least these:
· Ant's classpath must include an Ant.jar file and a JAR / CLASSES file that you have selected JAXP compatible XML parser. • When you need JDK's function (such as Javac Task or RMIC Task), the CLASSES.ZIP file for JDK1.1, JDK must be added to ClassPath, for JDK1.2 or JDK1.3, and Tools.jar is required. Ant support scripts, in the bin directory, if an ANT_HOME environment variable is set, the class of JDK will be loaded. · When you perform a specific platform program, such as Exex Task or CVS Task, Ant.home's properties must point to the installation directory of Ant, similarly, the script belt with Ant uses the ANT_HOME environment variable to automatically set this property.
The Ant Shell script is provided supports an Ant_OPTS environment variable, which is used to provide additional optional options. Some scripts stored under the Users Home directory (can be used to set options) are also read.
Build an ANT (Building Ant)
You can install an Source form in the form of the cvs, or from the Checkout Ant module to building Ant.
After installing the source code, enter the installation directory.
Set the Java_Home environment variable points to the JDK installation directory. If you want to know how to do, please refer to install the ANT section.
Make sure you have downloaded any auxiliary JAR file so that builds you are interested in Task. These JAR files can be placed in the classpath or in the lib directory. See the dependency part of the library that different TASK needs those JAR files. Note that these JAR files are just used as build Ant. To run Ant, you have to set these JAR files as doing in the installation of the ANT section.