Apache Ant is a java-based software build tool (build tool). In theory, it is somewhat similar to the C/C++ make tool
Overview
ant is a tool that automates software compilation, testing, deployment and other steps. It is mostly used in Java environments. software development. In actual software development, there are many places where ant can be used.
Development environment:
System: Windows
JDK: 1.6+
IDE: eclipse
ant: 1.9.1
##Advantages
ant is a sub-project in the JAKARTA directory of the Apache Software Foundation. It has the following advantages:1. Cross-platform Performance: Ant is written in pure Java language, so it has good cross-platform performance.
2. Simple operation: Ant is composed of a built-in task and optional tasks. Using ant tasks is like writing a command line in DOS. Ant requires an XML file (build file) when running. Ant can execute various tasks by calling the target tree. Each task implements a specific interface object.
3. Simple maintenance, good readability, and simple integration: Since Ant build files are in XML format, they are easy to maintain and write, and the structure is very clear. Ant can be integrated into the development environment. Due to Ant's cross-platform nature and simple operation, it is easy to integrate into some development environments.
Because these previous build tools have limitations, the original author of Ant Intolerable when developing software across multiple platforms.
Ant removes the functionality of some shell commands (such as
find . -name foo -exec rm {}), but it provides similar functionality, a cross-platform (work anywhere and everywhere) capability . If you really need to execute these shell commands, Ant has an
task that allows executing different commands depending on the operating system being executed.
Each build file contains a project and at least one default target. Goals contain tasks.
ProjectsA
projectcontains the following 3 attributes
Optionally, a description of the item may be provided by a top-level
element.
Each project defines one or more goals. A goal is a set of tasks you want to perform. When you start Ant, you can select the target to execute. When there is no target, the project's default value is used.
Targets
A target can depend on another target using thedependsattribute.
For example, you might have a target for compilation, and a target for release. When you execute the release target you have to execute the compile target first, so the release target depends on the compile target. It should be noted that Ant'sdependsattribute, if the target it depends on is not executed, but directly executes the current target, it will automatically execute the dependent target.
Tasks
A task is a piece of code that can be executed. A task can have multiple properties (or parameters, if you prefer).
The value of an attribute may contain a reference to the attribute. These references will be resolved before the task is executed.
Tasks have a common structure:
nameis the name of the task,attributeNis the attribute name, andvalueNis the value of the attribute.
All tasks share a task name attribute. The value of this property will be used for log messages generated by Ant.
Properties
Description | |
---|---|
Project name | |
is not The default target to use when supplying the target | |
The base directory where all path calculations are done. | This attribute may be overridden by the preset "basedir" attribute. If neither this property nor the property value is set, the directory path where the build file build.xml is located will be used. |
The above is the detailed content of Getting started with Ant. For more information, please follow other related articles on the PHP Chinese website!