Ant Official Website: http://ant.apache.org/ant introduction Ant is a sub-project of the Apache project, is a Java-based build tool. ANT is similar to the Make tool, but there is no shortcoming of traditional Make tools. Traditional MAKE often can only be used on a platform. Ant itself implements the Java class. The project's profile to be constructed is described in XML format. It can easily implement multi-platform compilation, which is ideal for Build Large Works. 1. Installation Configuration Ant: Ant can be downloaded from http://ant.apache.org, the latest version is 1.5.3 (this is an introduction to version 1.5.2). After downloading, the directory is directly decompressed, the directory is as follows: Ant - bin // Contains Launcher Scripts | - LIB // Contains Ant Jars Plus Necessary Dependencies | - DOCS // Contains Documentation | - Ant2 // A Brief Description of Ant2 Requirements | || - Image // Various Logos for HTML Documentation | || - Manual // Ant Documentation (A Must Read) | - ETC Requires Environment Variables: Ant_Home: Ant Install the directory java_home: JDK installation directory PATH: Plug the% Ant_HOME% / bin directory to the PATH variable so that the ANT is run directly from the command line to assume the ANT is installed in C: / Ant JDK D: /J2SDK1.4.0 is in command The following command is executed: set Ant_home = C: / ANTSET JAVA_HOME = D: /J2SDK1.4.0Set Path =% PATH%; C: / Ant / BIN When working at Win2000 Command Tips, each time you must perform it. After setting, after exiting the command prompt, the values of these variables will return to the original look. To avoid these troubles, you can set in the control panel / system / advanced / environment variable. Once the above setting is complete, Ant can be used. 2. Establish an engineering description file BUILD.XML is very convenient to build a large-scale project with ANT, each project corresponds to a build.xml file, which contains path information and tasks related to this project.
Here is an example of build.xml:
Target contains task elements, tasks are an executable code, and each task element has an ID property to facilitate reference in the file. Ant has built-in task sets available, such as Property, Javac, and War used in the above file, complete setting properties, compile and package tasks, respectively. Of course, if you need it, you can also write your own task. Build.xml's root element is Progject, which has three attributes name default basedir, where default is required. Name Specifies the name of the project, basedir represents the base path of the project, set to "." indicates the path where build.xml is located. Default represents the default target, if you do not specify a Target, use the Default Target.Property task to set the properties, one project can set a lot of properties, the properties are named and values, and the property is set to be referenced later.