The completion state is that of the then or else job. If either don't exist then the Job is flagged as complete.
If any more than three jobs are provided the extra jobs are ignored.
jobs | The child jobs. |
name | A name, can be any text. |
state | The state condition to check against. |
stop | Read only view of the internal stop flag. |
Example 1 | If a file exists. |
Example 2 | An example showing lots of if's. |
Configured By | ELEMENT |
Access | WRITE_ONLY |
Required | At least one. |
The child jobs.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. |
A name, can be any text.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No, defaults to COMPLETE. |
The state condition to check against. See the Oddjob User guide for a full list of state conditions.
Access | READ_ONLY |
Required | Read only. |
Read only view of the internal stop flag. This flag is cleared with a reset.
If a file exists.
<oddjob id="this" xmlns:state="http://rgordon.co.uk/oddjob/state"> <job> <state:if> <jobs> <exists name="Check File Exists" file="${this.dir}/data/some.txt"/> <echo id="then" name="Echo to Console">File Exists</echo> <echo id="else" name="Echo to Console">File Doesn't Exist</echo> </jobs> </state:if> </job> </oddjob>
An example showing lots of if's. All these if's go to COMPLETE state when run.
<oddjob> <job> <sequential xmlns:state="http://rgordon.co.uk/oddjob/state"> <jobs> <state:if> <jobs> <echo>Hello</echo> <echo>Good Bye</echo> </jobs> </state:if> <state:if> <jobs> <state:flag name="Exception" state="EXCEPTION"/> <state:flag name="Unexpected 1" state="EXCEPTION"/> <echo>No Hello</echo> </jobs> </state:if> <state:if> <jobs> <echo>Only Hello</echo> </jobs> </state:if> <state:if state="!COMPLETE"> <jobs> <state:flag name="Exception" state="EXCEPTION"/> <echo>No Hello</echo> </jobs> </state:if> <state:if state="!COMPLETE"> <jobs> <echo>Hello</echo> <state:flag name="Unexpected 2" state="EXCEPTION"/> </jobs> </state:if> <state:if state="!EXCEPTION"> <jobs> <echo>Hello</echo> <echo>Good Bye</echo> <state:flag name="Unexpected 3" state="EXCEPTION"/> </jobs> </state:if> </jobs> </sequential> </job> </oddjob>