Вы можете заставить каждое из них определять общее свойство и выполняться, только если это свойство еще не установлено:
<target name="a" unless="aOrBAlreadyRun">
<property name="aOrBAlreadyRun" value="true"/>
...
</target>
<target name="b" unless="aOrBAlreadyRun">
<property name="aOrBAlreadyRun" value="true"/>
...
</target>
См. http://ant.apache.org/manual/targets.html для объяснений.
РЕДАКТИРОВАТЬ:
Если вы хотите, чтобы сборка завершилась неудачно при выполнении обеих целей, то произойдет сбой, если свойство уже установлено:
<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>