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. 3 Preparation BuildFile written by 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 ProjectsProject has the following attribute: Attribute Description RequiredName project name. NodeFault When you use the default Target YesBaseDIR 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 element (see Description Section). A project can define one or more Targets. A Target is a series of what you want to do. When performing Ant, you can choose to execute that Target. When there is no Target, use the Target determined by the Project's Default property. 3.2 Targets A Target can depend on other Targets. For example, you may have a Target for compiler, a Target to generate an executable. You must compile the pass before generating an executable, so the target that generates executable files depends on compiling Targets. Ant will deal with this dependency. However, it should be noted that Ant's Depends attribute specifies the order of Target should be executed - if the dependent target cannot be run, this depends has no effect on target specified dependencies. Ant will perform each target in order (from left to right) in the order of Target in the Depends property. However, it is necessary to remember that as long as a Target relies on a Target, the latter will be executed first. Assume that we have to perform Target D. From its dependency properties, you may think that C, then B, and final A is executed. Wrong, C depends on B, B depends on A, so before the A, then B, then C, and final D is executed. A Target can only be executed once, and there are multiple Targets depending on it (see the above example). If (or if not) certain attributes are set, a Target is executed. In this way, the process of Build is allowed to better control the process of the system according to the status of the system (Java Version, OS, command line attribute, etc.).
To make a target element, you should join the IF (or UNSS) property in the Target element, with the target of the determined attribute. For example: Target will always be executed if there is no IF or UNSS attribute. Optional Description attributes can be used to provide a line description for Target, which can be output by the -projecthelp command line option. Well your TSTamp Task is a good practice in a so-called initial Target, and other Targets rely on this initial Target. To ensure that the initialization Target is the first Target that appears in other Target rerequisites. Most of the initial Target in this manual is "init". Target has the following properties: Attribute Description RequiredName Target's name YESDepends lists with a comma-separated name, 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: This is the name of Task, attribute is the property name, VALUEN is the attribute value. There is a built-in Task, as well as some optional Task, but you can also write your own task. All Task has a Task name property. ANT uses attribute values to generate log information. You can assign a ID attribute to Task: Here TaskName is the name of Task, and TaskID is the unique identifier of this task. With this identifier, you can reference the corresponding Task in the script. For example, in the script you can: