Reputation: 24747
In ANT, it is easy to set target dependency by using the attribute target.depends.
But how can I setup some target that they are exclusive to each other. So it will check the target combination before execute them?
Upvotes: 1
Views: 140
Reputation: 24747
The best way to do exclusive that is very simple.
Just don't write them into same build.xml file but make a copy of it and modify two version accordingly.
Upvotes: 0
Reputation: 691775
You could make each of them define a common property, and be executed only if this property is not set yet :
<target name="a" unless="aOrBAlreadyRun">
<property name="aOrBAlreadyRun" value="true"/>
...
</target>
<target name="b" unless="aOrBAlreadyRun">
<property name="aOrBAlreadyRun" value="true"/>
...
</target>
See http://ant.apache.org/manual/targets.html for explanations.
EDIT :
If you want the build to fail when both targets are executed, then fail if the property is already set :
<target name="a">
<fail if="aOrBAlreadyRun"
message="You can't have a and b executed in the same build"/>
<property name="aOrBAlreadyRun" value="true"/>
...
</target>
<target name="b">
<fail if="aOrBAlreadyRun"
message="You can't have a and b executed in the same build"/>
<property name="aOrBAlreadyRun" value="true"/>
...
</target>
Upvotes: 4