Command-line Arguments

Several tasks take arguments that will be passed to another process on the command line. To make it easier to specify arguments that contain space characters, nested arg elements can be used.

Attribute

Description

Required

value

a single command-line argument; can contain space characters.

Exactly one of these.

file

The name of a file as a single command-line argument; will be replaced with the absolute filename of the file.

path

A string that will be treated as a path-like string as a single command-line argument; you can use ; or : as path separators and Ant will convert it to the platform's local conventions.

pathref

Reference to a path defined elsewhere. Ant will convert it to the platform's local conventions.

line

a space-delimited list of command-line arguments.

prefix

A fixed string to be placed in front of the argument. In the case of a line broken into parts, it will be placed in front of every part. Since Ant 1.8.

No

suffix

A fixed string to be placed immediately after the argument. In the case of a line broken into parts, it will be placed after every part. Since Ant 1.8.

No

It is highly recommended to avoid the line version when possible. Ant will try to split the command line in a way similar to what a (Unix) shell would do, but may create something that is very different from what you expect under some circumstances.

Examples

<arg value="-l -a"/>

is a single command-line argument containing a space character, not separate commands "-l" and "-a".

<arg line="-l -a"/>

This is a command line with two separate arguments, "-l" and "-a".

<arg path="/dir;/dir2:\dir3"/>

is a single command-line argument with the value \dir;\dir2;\dir3 on DOS-based systems and /dir:/dir2:/dir3 on Unix-like systems.