Build.xml
All build files require the project element and at least one target element.
Project
This is root element.
<project name="JavaCCProject" default="compile" basedir=".">
</project>
- name: the name of the project. (Optional)
- default: the default target for the build script. A project may contain any number of targets. This attribute specifies which target should be considered as the default. (Mandatory)
- basedir: the base directory (or) the root folder for the project. (Optional)
property
Sets a property (by name and value)
target
A target is a collection of tasks that you want to run as one unit.
Targets can have dependencies on other targets.
- name The name of the target (Required)
- depends Comma separated list of all targets that this target depends on. (Optional)
- description A short description of the target. (optional)
- if Allows the execution of a target based on the trueness of a conditional attribute. (optional)
- unless Adds the target to the dependency list of the specified Extension Point. An Extension Point is similar to a target, but it does not have any tasks. (Optional)
Task reference
http://ant.apache.org/manual/
https://ant.apache.org/manual/tasksoverview.html
Command Line
ant [options] [target...]
The commonly used options are:
- -projecthelp displays the names and descriptions of targets in the build file.
- -buildfile <build filename> uses the specified build file instead of build.xml.
- -Dkey=value sets a Java property for Ant to use.
- -propertyfile <filename> sets properties for every line in the specified file.
To define a property
Use property task in build.xml
<property name="attribute" value="value"/>
Use environment variable
$ export attribute=value
Use following line in build.xml to retrieve.
<property environment="env"/>
<property name="attribute" value="${env.attribute}"/>
Use command line definition
ant -Dattribute=value task