Run an Apache Ant script.
| Package: | org.apache.ant |
| Category: | Execution tasks |
| Since: | 0.5 |
| EntityFS-aware? | No |
| Implements: | ActionTaskFactory
|
Description
Run an Apache Ant script in a forked process.
Required properties
Properties
| arguments | top |
Arguments to the program. The arguments will be given to the program in the order that they are added.
- Setter method:
-
addArgument(java.lang.String arg)
where:
arg– The program argument, for instance-f out.txt.
Add one program argument. - Setter method:
-
addArguments(Collection<? extends java.lang.String> args)
where:
args– A collection of program arguments.
Add a collection of program arguments. The arguments are added in the order that they are returned from the collection.
| configurators | top |
A collection of Configurator:s. Configurator:s are used to configure a task right before it is run in a TaskExecutor with properties that are not available until all of the task's dependencies have been run.
Build scripts that don't use TaskExecutor:s don't have to use Configurator:s.
- Setter method:
-
addConfigurator(Configurator cf)
where:
cf– A configurator.
Add one configurator. - Setter method:
-
addConfigurators(Collection<? extends Configurator> c)
where:
c– A collection of configurators.
Add a collection of configurators.
| emacsLogging | top |
Ant's Emacs logging property.
- Setter method:
-
setEmacsLogging(boolean b)
where:
b– Enable Emacs logging?
- Default value:
- Off
| environmentVariables | top |
Environment variables for the program. By default, the variables set are added
to the environment of the Schmant script, see the
inheritEnvironmentVariables property.
- Setter method:
-
addEnvironmentVariable(java.lang.String name, java.lang.String value)
where:
name– The environment variable name, for instancePATH.
value– The value of the variable.
- Setter method:
-
addEnvironmentVariables(Collection<String> vars)
where:
vars– A collection of environment variables given on the formNAME=VALUE.
Add a collection of environment variables. - See also:
- inheritEnvironmentVariables
| failOnErrors | top |
If the program exits with an error (an exit code != 0), should the task fail? See also ErrorIgnoringTF.
- Setter method:
-
setFailOnErrors(boolean b)
where:
b– Should the task fail on errors?
- Default value:
-
true(fails on errors)
| inheritEnvironmentVariables | top |
Should the environment variables of the Schmant script be inherited?
- Setter method:
-
setInheritEnvironmentVariables(boolean b)
where:
b– Should environment variables be inherited?
- Default value:
true(environment variables are inherited)- See also:
- environmentVariables
| keepGoing | top |
Ant's keep going property. (Should Ant keep going if a task fails?)
- Setter method:
-
setKeepGoing(boolean b)
where:
b– Keep going?
- Default value:
- Off
| logFile | top |
A file to log the output from Ant to.
- Setter method:
-
setLogFile(FutureEntity f)
where:
f– The log file.
- Default value:
- Log to stdout and stderr.
| logFooter | top |
The message that is logged to info level
after the task has been successfully run.
- Setter method:
-
setLogFooter(java.lang.String s)
where:
s– The footer message.
- Default value:
- Empty (no footer message is logged.)
| logHeader | top |
The message that is logged to info level
before the task is run.
- Setter method:
-
setLogHeader(java.lang.String s)
where:
s– The header message.
- Default value:
- A task class specific message.
| logLevel | top |
Ant's log level.
- Setter method:
-
setLogLevel(AntLogLevel l)
where:
l– The log level.
| noUserLib | top |
Ant's noUserLib property.
- Setter method:
-
setNoUserLib(boolean b)
where:
b– SetnoUserLib?
| properties | top |
A map of Ant properties for the script.
- Setter method:
-
addProperty(java.lang.String name, java.lang.String value)
where:
name– The property name.
value– The property value.
Add one property. - Setter method:
-
addProperties(Map<String, String> m)
where:
m– The property map.
Add a map of properties.
| propertyFile | top |
A property file, used by Ant.
- Setter method:
-
setPropertyFile(java.lang.Object o)
where:
o– The property file. Interpreted byArgumentInterpreter.getFile(java.lang.Object).
| source (required) | top |
The Ant script to run. The basedir for the
script, if it is not set, will be the directory of the Schmant script.
- Setter method:
-
setSource(java.lang.Object o)
where:
o– The script. Interpreted byArgumentInterpreter.getFile(java.lang.Object).
Set a script. - Setter method:
-
setSourceBody(java.lang.String s)
where:
s– The script body.
Set the script body, i.e. the contents of theprojecttag. The project tag sets the default targetdoit. - Setter method:
-
setSourceTargetBody(java.lang.String s)
where:
s– The script target body.
Set the body of a script target. This is convenient to use when the script should have only one target.
| stderrStrategy | top |
A ProcessOutputStrategy
for handling the program's output to stderr.
- Setter method:
-
setStderrStrategy(ProcessOutputStrategy s)
where:
s– Thestderrstrategy.
- Default value:
- A LoggingProcessOutputStrategy
that logs output to the
Level.SEVERE - See also:
- stdoutStrategy
| stdoutStrategy | top |
A ProcessOutputStrategy
for handling the program's output to stdout.
- Setter method:
-
setStdoutStrategy(ProcessOutputStrategy s)
where:
s– Thestdoutstrategy.
- Default value:
- A LoggingProcessOutputStrategy
that logs output to the
Level.INFO - See also:
- stderrStrategy
| targets | top |
The targets to run in the Ant script. The targets will be run in the order that they are added.
- Setter method:
-
addTarget(java.lang.String name)
where:
name– A target.
Add one target. - Setter method:
-
addTargets(Collection<String> c)
where:
c– The collection.
Add a collection of targets. The targets are added in the order that they are returned when iterating over the collection. - Default value:
- Not set. (Run the script's default target.)
| workingDirectory | top |
The working directory for the program. (The directory that the program is started in.)
- Setter method:
-
setWorkingDirectory(java.lang.Object o)
where:
o– A directory. Interpreted byArgumentInterpreter.getFile(java.lang.Object).
- Default value:
- The Schmant process' working directory. The Schmant launcher scripts sets this to the directory where the current script file is.
Examples
Example 1
Run the Ant script in the file f.
Example 2
Run an inline script that
prints out the contents of the variable s.
new AntTF().
setSource(
new CharSequenceReadableFile(
"<project name=\"my_project\" default=\"prints\">\n" +
"<target name=\"prints\">\n" +
" <echo>" + s + "</echo>\n" +
"</target>\n" +
"</project>")).run();
Example 3
Run an inline script (using setSourceBody)
that prints out the contents of the variable s.
new AntTF().
setSourceBody(
"<target name=\"doit\">\n" +
" <echo>" + s + "</echo>\n" +
"</target>").run();
Example 4
Run an inline script (using setSourceTargetBody)
that prints out the contents of the variable s.
new AntTF().
setSourceTargetBody("<echo>" + s + "</echo>").run();
Example 5
Run an inline script (using setSourceTargetBody)
that prints out the contents of the variable s. The variable
s is assigned to the property s in the Ant script.
new AntTF().
setSourceTargetBody("<echo>${s}</echo>").
addProperty("s", s).run();
That a task is not EntityFS-aware means that it is not aware of
DirectoryView filters (it uses them as plain
Directory:s) and also that it usually requires that the entities it
takes as arguments are in a File-based file file system.
(That they are ECFileResolvable.)