public class AntRunner extends Object
This class is designed to programmatically invoke Ant targets
1. initialize a new Project by calling "init"
2. invoke the deployment by running the deploy* Ant Target and feeding Ant with the following properties:
- gar.name/jar.name
- package.source.dir
- package.name
- package.file
You'll need ant-launcher.jar ant.jar to compile.
Example :
try {
//init
init("/home/me/build.xml","/home/me/");
//properties
HashMap m = new HashMap();
m.put("event", "test");
m.put("subject", "sujet java 3");
m.put("message", "message java 3");
setProperties(m, false);
//run
runTarget("test");
} catch (Exception e) { e.printStackTrace(); }
| Modifier and Type | Field and Description |
|---|---|
protected org.apache.commons.logging.Log |
logger |
| Constructor and Description |
|---|
AntRunner()
Creates a new Ant runner
|
| Modifier and Type | Method and Description |
|---|---|
void |
init(String _buildFile,
String _baseDir)
Initializes a new Ant Project.
|
void |
runScript()
Executes an external scripts
|
void |
runTarget(String _target)
Runs the given Target.
|
void |
setProperties(Map _properties,
boolean _overridable)
Sets the project's properties.
|
public void init(String _buildFile, String _baseDir) throws AntInterfaceException
_buildFile - The build File to use. If none is provided, it
will be defaulted to "build.xml"._baseDir - The project's base directory. If none is provided,
will be defaulted to "." (the current directory).AntInterfaceException - if the initialization failspublic void setProperties(Map _properties, boolean _overridable) throws AntInterfaceException
_properties - A map containing the properties' name/value
couples_overridable - If set, the provided properties values may be
overriden by the config file's valuesAntInterfaceException - if the project is null or the properties are nullpublic void runTarget(String _target) throws AntInterfaceException
_target - The name of the target to run. If null, the
project's default target will be used.AntInterfaceException - if an error occurs during the executionpublic void runScript()
throws AntInterfaceException
AntInterfaceException - if an error occurs during the executionCopyright © 2015. All Rights Reserved.