Ant practice
What is it? -------------------------------------------------- ---------------------------- Ant is a Java-based build tool. In theory, it is some similar (unix) Make, but there is no Make's defect. 2. Install ANT ---------------------------------------------------------------------------------------------- -------------------------------- Ant has two installation methods, one is to use the compiled binary The file is installed, and the other is the source code you build Ant. Download address: http://ant.apache.org/ Installing the ANTBINARY 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. Windows assumes that Ant is installed in a C: / Ant / directory. The following is a command to set the environment: set ant_home = c: / antset java_home = c: /jdk1.2.2set path =% path%;% ant_home% / bin unix (bash) assumes Ant installation in / usr / local / ant directory under. The following is a command to set the environment: export ant_home = / usr / local / anteexport java_home = / usr / local / jdk-1.2.2export path = $ {pat}: $ {ant_home} / bin 3. Run Ant ------ -------------------------------------------------- -------------------------- Run 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.
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 produce logging information without adornments-logfile file use given file for log output-logger classname the class that 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 Towards The root of the filesystem and use the first one found-dproperty = value set print - DPRUE Example Ant Use the build.xml in the current directory runs Ant, performs 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 of Dist runs Ant using Test.xml in the current directory, performs 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. 4. 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 following Task section) ProjectsProject has the following properties: Attribute Description Required Name project name. No Default When the default Target Yes basedIr 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 in BUILDIR Property. The description of the NO project appears in the form of a top
For example: