org.gcube.common.vremanagement.deployer.impl.operators.ant
Class AntRunner

java.lang.Object
  extended by org.gcube.common.vremanagement.deployer.impl.operators.ant.AntRunner

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(); }
 
 


Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
AntRunner()
          Creates a new Ant runner
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected org.apache.commons.logging.Log logger
Constructor Detail

AntRunner

public AntRunner()
Creates a new Ant runner

Method Detail

init

public void init(String _buildFile,
                 String _baseDir)
          throws AntInterfaceException
Initializes a new Ant Project.

Parameters:
_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).
Throws:
AntInterfaceException - if the initialization fails

setProperties

public void setProperties(Map _properties,
                          boolean _overridable)
                   throws AntInterfaceException
Sets the project's properties. May be called to set project-wide properties, or just before a target call to set target-related properties only.

Parameters:
_properties - A map containing the properties' name/value couples
_overridable - If set, the provided properties values may be overriden by the config file's values
Throws:
AntInterfaceException - if the project is null or the properties are null

runTarget

public void runTarget(String _target)
               throws AntInterfaceException
Runs the given Target.

Parameters:
_target - The name of the target to run. If null, the project's default target will be used.
Throws:
AntInterfaceException - if an error occurs during the execution

runScript

public void runScript()
               throws AntInterfaceException
Executes an external scripts

Throws:
AntInterfaceException - if an error occurs during the execution


Copyright © 2012. All Rights Reserved.