Run an Apache Ant script.
Task package: | org.apache.ant |
Java package: | org.schmant.task.apache.ant |
Category: | Execution tasks |
Since: | 0.5 |
EntityFS-aware? | No* |
Implements: | ActionTaskFactory |
Description:
This task runs an Apache Ant script in its own process.
The script to run may be a complete Ant script, the body of an Ant script or a single target. See the source property.
Required properties
Properties
arguments | top |
Arguments to the Ant launcher (ant
or
ant.bat
). The arguments will be given to the
program in the order that they are added.
- Setter method:
addArgument(String arg)
Add one program argument.parameters:arg
– The program argument, for instance-nice 10
.- Setter method:
addArguments(Object o)
Add one program argument or an array or a collection of program arguments.parameters:o
– A program argument or an array or collection of program arguments (strings).- Setter method:
clearArguments()
Clear the list of program arguments.
emacsLogging | top |
Ant's Emacs logging property.
- Setter method:
setEmacsLogging(boolean b)
parameters: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(String name, String value)
parameters:name
– The environment variable name, for instancePATH
.value
– The value of the variable.- Setter method:
addEnvironmentVariables(Object o)
Add one or several environment variables.parameters:o
– A string or an array or collection of strings. Each string must have the formatNAME=VALUE
.- Setter method:
clearEnvironmentVariables()
Clear the 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)
parameters: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)
parameters: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)
parameters:b
– Keep going?- Default value:
false
libPathDecorators | top |
A list of PathDecorator:s that are used to create paths where Ant will search for Jars and classes to add to its classpath. The path entries derived from this property are added to the library path after the entries from the libPathEntries property.
This corresponds to Ant's -lib
option.
- Setter method:
addLibPathDecorator(PathDecorator pd)
Add one library path decorator.parameters:pd
– A path decorator.- Setter method:
addLibPathDecorators(Object o)
Add one or several library path decorators.parameters:o
– A library path decorator or an array or collection of library path decorators (PathDecorator objects).- Setter method:
clearLibPathDecorators()
Clear the list of library path decorators.- See also:
- libPathEntries
libPathEntries | top |
A list of paths where Ant will search for Jars and classes to add to its classpath. The path entries added to this property are added to the library path before the entries derived from the libPathDecorators property.
This corresponds to Ant's -lib
option.
- Setter method:
addLibPathEntries(Object o)
Add one or several library path entries.parameters:- Setter method:
addLibPathEntry(Object o)
Add one or several library path entries.parameters:- Setter method:
clearLibPathEntries()
Clear the list of library path entries.- See also:
- libPathDecorators
logFile | top |
A file to log the output from Ant to.
- Setter method:
setLogFile(Object f)
parameters:- 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(String s)
parameters:s
– The footer message.- Default value:
- Empty (no footer message is logged.)
- See also:
- logHeader
logHeader | top |
The message that is logged to info
level
before the task is run.
- Setter method:
setLogHeader(String s)
parameters:s
– The header message.- Default value:
- A task class specific message.
- See also:
- logFooter
logLevel | top |
Ant's log level.
- Setter method:
setLogLevel(AntLogLevel l)
parameters:l
– The log level.
noUserLib | top |
Ant's noUserLib
property.
- Setter method:
setNoUserLib(boolean b)
parameters:b
– SetnoUserLib
?
properties | top |
A map of Ant properties for the script.
- Setter method:
addProperties(Map<String, String> m)
Add a map of properties.parameters:m
– The property map.- Setter method:
addProperty(String name, String value)
Add one property.parameters:name
– The property name.value
– The property value.- Setter method:
clearProperties()
Clear the property map.
propertyFile | top |
A property file, used by Ant.
- Setter method:
setPropertyFile(Object o)
parameters:
reportLevel | top |
This property is used to change the Report level for all task created by this task factory. The report level is changed for the thread running the task when the it is run, and is restored to its previous level when the it is done.
- Setter method:
setReportLevel(Level l)
Set the report levelparameters:l
– The new report level.
source (required) | top |
The Ant script to run. The basedir
for the
script, if it is not set in the script, will be set to the directory of the
Schmant script.
- Setter method:
setSource(Object o)
Set a script.parameters:- Setter method:
setSourceBody(String s)
Set the script body, i.e. the contents of theparameters:project
tag. The project tag sets the default targetdoit
.s
– The script body.- Setter method:
setSourceTargetBody(String s)
Set the body of a script target. This is convenient to use when the script should have only one target.parameters:s
– The script target body.
stderrStrategy | top |
A ProcessOutputStrategy
for handling the program's output to stderr
.
- Setter method:
setStderrStrategy(ProcessOutputStrategy s)
parameters:s
– Thestderr
strategy.- 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)
parameters:s
– Thestdout
strategy.- 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(String name)
Add one target.parameters:name
– A target.- Setter method:
addTargets(Object o)
Add one target or an array or collection of targets.parameters:o
– A target or an array or collection of targets (strings).- Setter method:
clearTargets()
Clear the list of targets.- Default value:
- Not set. (Run the script's default target.)
traceLogging | top |
If trace logging is enabled for a task, it reports its configuration before it is run.
Trace logging may also be enabled globally for all tasks by calling TraceMode.setTraceMode(boolean).
- Setter method:
setTraceLogging(boolean b)
Enable or disable trace logging.parameters:b
– Enable trace logging?
workingDirectory | top |
The working directory for the program. (The directory that the program is started in.)
- Setter method:
setWorkingDirectory(Object o)
parameters:- 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
. f
may be a Java File or an EntityFS EFile.
Example 2
Run an inline script that
prints out the contents of the variable s
.
Example 3
Run an inline script (using setSourceBody
)
that prints out the contents of the variable s
.
Example 4
Run an inline script (using setSourceTargetBody
)
that prints out the contents of the variable s
.
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.
* 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.) A non File-resolvable entity can be made so by using the SchmantFileSystems.makeFileResolvable(org.entityfs.EFile) method.