What is ANT?
Ant is a BUILD tool based on Java and XML.
2 download, install ANT
Install ANT
Download the .zip file, unzipped to C: /rant1.3 (later reference to% Ant_HOME%)
2.1 Do you need to do some configuration before you run Ant.
2.1.1 Add a bin directory to the PATH environment variable.
2.1.2 Set the ANT_HOME environment variable, 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.
2.1.3 Optionally, set a Java_Home environment variable (refer to the following advanced sections), 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.
2.2 Run Ant
Running Ant is very simple, when you correctly install Ant, just enter Ant.
n When you 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.
n You can specify whether one or more Targets can be performed. When Target is omitted, the ANT uses the target attribute specified by the Default property of the label
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 running Ant, perform a Target called Dist and set the value of the build property of the build property.
3 Write Build.xml
Ant's buildfile is written with XML. Each buildfile contains a Project.
Each Task element in BuildFile can have an ID attribute that can be used to reference the specified task with this ID value. This value must be unique. (For details, please refer to the Task section below)
3.1 PROJECTS
Project has the following properties:
Attribute DescriptionRequiredName project name .NodeFault When the default targetyesbasedir used when not specified Target is used to calculate the base path of all other paths. This property can be overwritten by BaseDir Property. This property is ignored when it is overwritten. If the attributes are not set, the parent directory of the buildfile file is used. NO
The description of the project appears in the form of a top
Attribute Description RequiredName Target's name YESDepends is a list of named Target with a comma, which is the dependent table. NOIF executes the name of the attribute that Target needs to be set. Nounless executes the Target to clear the set properties name. NodeScription About Target features a short description. NO3.3 TASKS A Task is an executable code. A Task can have multiple properties (if you like, you can call it as a variable). Attributes may only contain references to Property. These references will be parsed before TASK execution. Below is a general constructor of Task: