Argument DataType
The apply,
exec, and java tasks accept
nested <arg> elements, specifying
command-line arguments for their respective process calls. The
org.apache.tools.ant.types.Commandline.Argument
class implements this DataType.[27] If several <arg>
elements are specified, each is treated as a separate argument to the
process call. Following is a list of all
<arg> attributes:
-
file(all, File,*) A filename as a single argument. In the buildfile, this filename is relative to the current working directory. The “current working directory” varies depending on the context this type is used in. The name is converted to an absolute path when passed as an argument.
-
line(all, String,*) A space-delimited list of multiple arguments.
-
path(all, Path, *) A path, as explained later in the section “Path DataType.”
-
value(all, String, *) A single command-line argument. Use this if your argument has spaces, but you still want to treat it as a single value.
Exactly one of these attributes is required.
Example
Let’s look at a complete buildfile to put things
into perspective. In Example 4-1, we use the
java task to invoke Apache’s
Xalan XSLT processor, transforming an XML file into HTML using
XSLT.[28] As you might expect, the
java task invokes any Java class with a
main( ) method. Use <arg>
elements to pass arguments to the java task.
Example 4-1. <arg> usage
<?xml version="1.0"?> <project name="arg demo" default="xslt" basedir="."> <property name="xalan.home" value="C:/java/xalan-j_2_1_0"/> <property ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access