public class AntJob extends SerializableJob implements Stoppable
Not all tasks have been tested!
Oddjob component properties can be referenced inside Ant tasks using the ${id.property} notation. Ant will look up the Oddjob property before it looks up properties defined with the <property> tag. The oddjob derived properties of an Ant task aren't constant. Oddjob variables can change unlike Ant properties.
Note: Ant looks up properties beginning with 'ant.' - Therefore no component can have an id of 'ant' as the lookup will fail to retrieve the properties from that component (unless of course the 'ant' component implements all the properties that Ant requires!).
A class path or class loader can be supplied and this will be used for task definitions and antlibs. Name space antlibs will only work if the antlib is placed in the oj-ant/lib directory. This is becuase name space ant libs require the ant lib to be loaded in the same class loader as Ant.
<oddjob id="this"> <job> <ant id="an-ant"> <output> <identify id="result"> <value> <buffer/> </value> </identify> </output> <tasks> <xml> <tasks> <echo message="${this.args[0]}"/> </tasks> </xml> </tasks> </ant> </job> </oddjob>
<ant> <tasks> <xml> <tasks> <property name="test.thing" value="Test"/> <echo message="${test.thing}"/> </tasks> </xml> </tasks> </ant>
<oddjob id="this"> <job> <sequential> <jobs> <variables id="v"> <fruit> <value value="Apples"/> </fruit> </variables> <ant> <tasks> <xml> <tasks> <taskdef name="result" classname="org.oddjob.ant.AntJobTest$ResultTask"/> <property name="our.fruit" value="${v.fruit}"/> <property name="v.fruit" value="Pears"/> <result key="one" result="${our.fruit}"/> <result key="two" result="${v.fruit}"/> </tasks> </xml> </tasks> </ant> </jobs> </sequential> </job> </oddjob>Note that the property defined in Ant does not override that defined in Oddjob (as per the rules of Ant). the result of both one and two is 'Apples'
<oddjob> <job> <sequential> <jobs> <variables id="v"> <fruit> <value value="Apples"/> </fruit> </variables> <ant id="defs"> <tasks> <xml> <tasks> <taskdef name="result" classname="org.oddjob.ant.AntJobTest$ResultTask"/> <property name="our.fruit" value="${v.fruit}"/> <property name="v.fruit" value="Pears"/> </tasks> </xml> </tasks> </ant> <ant project="${defs.project}"> <tasks> <xml> <tasks> <property name="our.fruit" value="Pears"/> <result key="three" result="${our.fruit}"/> <result key="four" result="${v.fruit}"/> </tasks> </xml> </tasks> </ant> </jobs> </sequential> </job> </oddjob>The first Ant job declares a task and properties that the second Ant project can access.
<oddjob> <job> <sequential name="Using Ant to Manipulate Files"> <jobs> <properties> <values> <value key="our.test.file.name" value="test.txt"/> </values> </properties> <ant baseDir="${work.dir}"> <tasks> <xml> <tasks> <patternset id="file.test"> <include name="${our.test.file.name}"/> </patternset> <touch file="${our.test.file.name}"/> <copy todir=".."> <fileset dir="."> <patternset refid="file.test"/> </fileset> </copy> <delete file="../${our.test.file.name}"/> <delete file="${our.test.file.name}"/> <echo message="Done."/> </tasks> </xml> </tasks> </ant> </jobs> </sequential> </job> </oddjob>
Constructor and Description |
---|
AntJob() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.ClassLoader |
buildAntClassLoader() |
protected int |
execute()
Execute the tasks.
|
java.io.File |
getBaseDir() |
java.lang.ClassLoader |
getClassLoader() |
java.lang.String |
getClassPath() |
java.lang.String |
getMessageLevel() |
java.io.OutputStream |
getOutput()
Return the ant tasks output.
|
org.apache.tools.ant.Project |
getProject()
Get the project used for the tasks.
|
java.lang.String |
getTasks() |
java.lang.String |
getVersion() |
protected void |
ineritProperties(org.apache.tools.ant.PropertyHelper propertyHelper) |
boolean |
isException() |
protected void |
onReset()
Allow sub classes to do something on reset.
|
protected void |
onStop()
Allow sub classes to do something on stop.
|
void |
setBaseDir(java.io.File baseDir) |
void |
setClassLoader(java.lang.ClassLoader classLoader) |
void |
setClassPath(java.lang.String classPath) |
void |
setException(boolean exception) |
void |
setMessageLevel(java.lang.String messageLevel) |
void |
setOutput(java.io.OutputStream out) |
void |
setProject(org.apache.tools.ant.Project project)
Set the project to use for the tasks.
|
void |
setTasks(java.lang.String xml) |
fireDestroyedState, force, getStateChanger, hardReset, iconHelper, isStop, onDestroy, run, sleep, softReset, stateHandler, stop
configure, getName, logger, logger, loggerName, save, setName, toString
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSession
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addStateListener, lastStateEvent, removeStateListener
public void setOutput(java.io.OutputStream out)
public java.io.OutputStream getOutput()
public org.apache.tools.ant.Project getProject()
public void setProject(org.apache.tools.ant.Project project)
project
- The project.public void setMessageLevel(java.lang.String messageLevel)
public java.lang.String getMessageLevel()
protected int execute() throws java.lang.Exception
protected void onStop()
SimpleJob
protected void onReset()
SimpleJob
protected void ineritProperties(org.apache.tools.ant.PropertyHelper propertyHelper)
protected java.lang.ClassLoader buildAntClassLoader() throws java.io.IOException
java.io.IOException
public boolean isException()
public void setException(boolean exception)
public java.io.File getBaseDir()
public void setBaseDir(java.io.File baseDir)
public java.lang.String getTasks()
public void setTasks(java.lang.String xml)
public java.lang.ClassLoader getClassLoader()
public void setClassLoader(java.lang.ClassLoader classLoader)
public java.lang.String getVersion()
Property: version
Description: The ant version.
public java.lang.String getClassPath()
public void setClassPath(java.lang.String classPath)