|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.oddjob.framework.BaseComponent
org.oddjob.framework.BasePrimary
org.oddjob.framework.SimpleJob
org.oddjob.framework.SerializableJob
org.oddjob.ant.AntJob
public class AntJob
Oddjob creates it's own Ant project to use internally this project can be shared between different AntJob jobs using the 'project' attribute. This allows taskdefs and properties to be defined in one place and shared in many jobs.
Oddjob component properties can be referenced inside an 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.
Not all tasks have been tested.
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!).
<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>
Field Summary |
---|
Fields inherited from class org.oddjob.framework.SimpleJob |
---|
stateHandler, stop |
Fields inherited from class org.oddjob.framework.BaseComponent |
---|
iconHelper |
Constructor Summary | |
---|---|
AntJob()
|
Method Summary | |
---|---|
protected int |
execute()
Execute the tasks. |
File |
getBaseDir()
|
ClassLoader |
getClassLoader()
|
String |
getMessageLevel()
|
OutputStream |
getOutput()
Return the ant tasks output. |
org.apache.tools.ant.Project |
getProject()
Get the project used for the tasks. |
String |
getTasks()
|
String |
getVersion()
|
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(File baseDir)
|
void |
setClassLoader(ClassLoader classLoader)
|
void |
setException(boolean exception)
|
void |
setMessageLevel(String messageLevel)
|
void |
setOutput(OutputStream out)
|
void |
setProject(org.apache.tools.ant.Project project)
Set the project to use for the tasks. |
void |
setTasks(String xml)
|
Methods inherited from class org.oddjob.framework.SimpleJob |
---|
fireDestroyedState, force, getStateChanger, hardReset, onDestroy, run, sleep, softReset, stateHandler, stop |
Methods inherited from class org.oddjob.framework.BasePrimary |
---|
configure, getName, logger, logger, loggerName, save, setName, toString |
Methods inherited from class org.oddjob.framework.BaseComponent |
---|
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSession |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.oddjob.Stoppable |
---|
stop |
Methods inherited from interface org.oddjob.Stateful |
---|
addStateListener, lastStateEvent, removeStateListener |
Constructor Detail |
---|
public AntJob()
Method Detail |
---|
public void setOutput(OutputStream out)
public OutputStream getOutput()
public org.apache.tools.ant.Project getProject()
public void setProject(org.apache.tools.ant.Project project)
project
- The project.public void setMessageLevel(String messageLevel)
public String getMessageLevel()
protected int execute() throws Exception
execute
in class SimpleJob
Exception
- If the unexpected occurs.protected void onStop()
SimpleJob
onStop
in class SimpleJob
protected void onReset()
SimpleJob
onReset
in class SimpleJob
public boolean isException()
public void setException(boolean exception)
public File getBaseDir()
public void setBaseDir(File baseDir)
public String getTasks()
public void setTasks(String xml)
public ClassLoader getClassLoader()
public void setClassLoader(ClassLoader classLoader)
public String getVersion()
Property: version
Description: The ant version.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |