Apache Ant Command Line Arguments
Sometimes, project’s task require arguments which will be passed to another process by using command line. Ant allows command line arguments, even arguments which contains space characters.
It supports <arg> element to pass arguments and uses various attribute given below.
Attributes
Attribute | Description | Required |
---|---|---|
value | It is a single line argument which may contain space characters. | No |
file | A file which is passed as a single line argument. | No |
path | A path passed as a single command-line argument. | Yes |
pathref | It is a path reference. | No |
line | A list of command-line arguments. | No |
prefix | A fixed string to be placed in front of the argument. | No |
suffix | A fixed string to be placed immediately after the argument. | No |
Ant treats command line and paths in Unix shell way and it is highly recommended to avoid the line attribute.
Example
It is a single line command line argument having space characters.
A command line argument with two separate options : -l and -a.
when we run only ant from command line without any argument, Ant look for the default file build.xml and execute target.
-build
This argument is used while running build file other than default build.xml.
Ex.
-find
It searches for build file, first into the current directory then in the parent directory and until the file is found.
It require filename, if not passed default build.xml is assumed.
Ex.
-Dproperty
It helps to set property value by using command line. Property is a name of property and value is a value associated to the property.
Ex.
-quiet
It is used to show less information to the console.
Ex.