org.leafcutter.core
Class TaskRunner

java.lang.Object
  extended by org.leafcutter.core.TaskRunner

public class TaskRunner
extends java.lang.Object

The main class in the Leafcutter API. The most important method is run(...) which allows you to execute an Ant task.

See the Leafcutter User Guide for more information.


Field Summary
protected static java.lang.String DEFAULT_TASKS
           
protected static java.lang.String DEFAULT_TYPES
           
 
Method Summary
static void addReference(java.lang.String refid, java.lang.String declaration)
          Add a reference with no properties.
static void addReference(java.lang.String refid, java.lang.String declaration, java.lang.Object arg1)
          Add a reference with one property.
static void addReference(java.lang.String refid, java.lang.String declaration, java.lang.Object[] args)
          Define a reference to type in the Leafcutter runtime.
static void addReference(java.lang.String refid, java.lang.String declaration, java.lang.Object arg1, java.lang.Object arg2)
          Add a reference with two properties.
static void addReference(java.lang.String refid, java.lang.String declaration, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
          Add a reference with three properties.
static void addReference(java.lang.String refid, java.lang.String declaration, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
          Add a reference with four properties.
static void addTaskDef(java.lang.String taskName, java.lang.String className)
          Define an Ant task in the Leafcutter runtime.
static void addTaskDefs(java.io.InputStream is)
          Define all tasks in a properties file in the Leafcutter runtime.
static void addTypeDef(java.lang.String typeName, java.lang.String className)
          Define an Ant type in the Leafcutter runtime.
static void addTypeDefs(java.io.InputStream is)
          Define all types in a properties file in the Leafcutter runtime.
static java.util.Map getAntProjectProperties()
          Get the values of the Ant properties which have been set as the result of executing some task,
static java.lang.String getAntProjectProperty(java.lang.String name)
          Get the value of an Ant property which has been set as the result of executing some task, e.g.
static Logger getLogger()
          Returns the singleton logger, allowing your application to write to the same logs as the Ant tasks that it uses.
static org.apache.tools.ant.Project getProject()
          Returns the singleton Project subclass which is used by all Ant tasks executed by Leafcutter
static void main(java.lang.String[] args)
           
static void removeReference(java.lang.String refid)
          Remove a previously-defined reference from the Leafcutter runtime.
static java.lang.String run(java.lang.String antCommand)
          Run an Ant task with no properties.
static java.lang.String run(java.lang.String antCommand, java.lang.Object arg1)
          Run an Ant task with one property.
static java.lang.String run(java.lang.String antCommand, java.lang.Object[] args)
          Run an Ant task.
static java.lang.String run(java.lang.String antCommand, java.lang.Object arg1, java.lang.Object arg2)
          Run an Ant task with two properties.
static java.lang.String run(java.lang.String antCommand, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
          Run an Ant task with three properties.
static java.lang.String run(java.lang.String antCommand, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
          Run an Ant task with four properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TASKS

protected static final java.lang.String DEFAULT_TASKS
See Also:
Constant Field Values

DEFAULT_TYPES

protected static final java.lang.String DEFAULT_TYPES
See Also:
Constant Field Values
Method Detail

addTypeDef

public static void addTypeDef(java.lang.String typeName,
                              java.lang.String className)
Define an Ant type in the Leafcutter runtime. The class implementing the type should be a subclass of org.apache.tools.ant.types.DataType.

Parameters:
typeName - used to refer to the type inside commands passed to run() or declarations passed to addReference()
className - fully qualifed name of the class implementing the type.

addTaskDef

public static void addTaskDef(java.lang.String taskName,
                              java.lang.String className)
Define an Ant task in the Leafcutter runtime. The class implementing the type should be a subclass of org.apache.tools.ant.Task.

Parameters:
taskName - used to refer to the task inside command strings passed to run()
className - fully qualifed name of the class implementing the task.

addTypeDefs

public static void addTypeDefs(java.io.InputStream is)
                        throws java.io.IOException
Define all types in a properties file in the Leafcutter runtime. The file should have lines of the format typeName = fullyQualifiedTypeClass

Parameters:
is - an InputStream created from the properties file
Throws:
java.io.IOException - problem loading properties from the file

addTaskDefs

public static void addTaskDefs(java.io.InputStream is)
                        throws java.io.IOException
Define all tasks in a properties file in the Leafcutter runtime. The file should have lines of the format taskName = fullyQualifiedTaskClass

Parameters:
is - an InputStream created from the properties file
Throws:
java.io.IOException - problem loading properties from the file

addReference

public static void addReference(java.lang.String refid,
                                java.lang.String declaration)
                         throws TaskRunnerException
Add a reference with no properties. Note, variable args will be used in JDK 5.0 version.

Throws:
TaskRunnerException
See Also:
addReference(String, String, Object[])

addReference

public static void addReference(java.lang.String refid,
                                java.lang.String declaration,
                                java.lang.Object arg1)
                         throws TaskRunnerException
Add a reference with one property. Note, variable args will be used in JDK 5.0 version.

Throws:
TaskRunnerException
See Also:
addReference(String, String, Object[])

addReference

public static void addReference(java.lang.String refid,
                                java.lang.String declaration,
                                java.lang.Object arg1,
                                java.lang.Object arg2)
                         throws TaskRunnerException
Add a reference with two properties. Note, variable args will be used in JDK 5.0 version.

Throws:
TaskRunnerException
See Also:
addReference(String, String, Object[])

addReference

public static void addReference(java.lang.String refid,
                                java.lang.String declaration,
                                java.lang.Object arg1,
                                java.lang.Object arg2,
                                java.lang.Object arg3)
                         throws TaskRunnerException
Add a reference with three properties. Note, variable args will be used in JDK 5.0 version.

Throws:
TaskRunnerException
See Also:
addReference(String, String, Object[])

addReference

public static void addReference(java.lang.String refid,
                                java.lang.String declaration,
                                java.lang.Object arg1,
                                java.lang.Object arg2,
                                java.lang.Object arg3,
                                java.lang.Object arg4)
                         throws TaskRunnerException
Add a reference with four properties. Note, variable args will be used in JDK 5.0 version.

Throws:
TaskRunnerException
See Also:
addReference(String, String, Object[])

addReference

public static void addReference(java.lang.String refid,
                                java.lang.String declaration,
                                java.lang.Object[] args)
                         throws TaskRunnerException
Define a reference to type in the Leafcutter runtime. References have global scope once created. Note that references have global scope. Once a reference is defined, it can be used in any subsequent call to run(). If a new reference with the same name is defined, it overwrites the old reference. References can be removed with removeReference(). References to tasks are not supported.

Parameters:
refid - the handle on the reference
declaration - the declaration string. See the Leafcutter User Guide for syntax
args - the arguments that are referred to by expressions like ${1} in the declaration
Throws:
TaskRunnerException - a problem occurred when parsing the declaration.

removeReference

public static void removeReference(java.lang.String refid)
Remove a previously-defined reference from the Leafcutter runtime. Has no effect if no reference exists with the specified refid.

Parameters:
refid - the handle on the reference

run

public static java.lang.String run(java.lang.String antCommand)
                            throws TaskRunnerException
Run an Ant task with no properties. Note, variable args will be used in JDK 5.0 version.

Throws:
TaskRunnerException
See Also:
run(String, Object[])

run

public static java.lang.String run(java.lang.String antCommand,
                                   java.lang.Object arg1)
                            throws TaskRunnerException
Run an Ant task with one property. Note, variable args will be used in JDK 5.0 version.

Throws:
TaskRunnerException
See Also:
run(String, Object[])

run

public static java.lang.String run(java.lang.String antCommand,
                                   java.lang.Object arg1,
                                   java.lang.Object arg2)
                            throws TaskRunnerException
Run an Ant task with two properties. Note, variable args will be used in JDK 5.0 version.

Throws:
TaskRunnerException
See Also:
run(String, Object[])

run

public static java.lang.String run(java.lang.String antCommand,
                                   java.lang.Object arg1,
                                   java.lang.Object arg2,
                                   java.lang.Object arg3)
                            throws TaskRunnerException
Run an Ant task with three properties. Note, variable args will be used in JDK 5.0 version.

Throws:
TaskRunnerException
See Also:
run(String, Object[])

run

public static java.lang.String run(java.lang.String antCommand,
                                   java.lang.Object arg1,
                                   java.lang.Object arg2,
                                   java.lang.Object arg3,
                                   java.lang.Object arg4)
                            throws TaskRunnerException
Run an Ant task with four properties. Note, variable args will be used in JDK 5.0 version.

Throws:
TaskRunnerException
See Also:
run(String, Object[])

run

public static java.lang.String run(java.lang.String antCommand,
                                   java.lang.Object[] args)
                            throws TaskRunnerException
Run an Ant task.

Parameters:
antCommand - the command string. See the Leafcutter User Guide for syntax
args - the arguments that are referred to by expressions like ${1} in the command
Returns:
the complete console output of the task.
Throws:
TaskRunnerException - a problem was encountered when initialising the task

getAntProjectProperty

public static java.lang.String getAntProjectProperty(java.lang.String name)
Get the value of an Ant property which has been set as the result of executing some task, e.g. tstamp.

Parameters:
name - the name of the property
Returns:
the property value

getAntProjectProperties

public static java.util.Map getAntProjectProperties()
Get the values of the Ant properties which have been set as the result of executing some task,

Returns:
the properties value

getLogger

public static Logger getLogger()
Returns the singleton logger, allowing your application to write to the same logs as the Ant tasks that it uses.

Returns:
The Logger

getProject

public static org.apache.tools.ant.Project getProject()
Returns the singleton Project subclass which is used by all Ant tasks executed by Leafcutter

Returns:
The project

main

public static void main(java.lang.String[] args)