Bug 23629

Summary: Allow antcall to have if/unless like target does.
Product: Ant Reporter: Ben Litchfield <ben>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: REOPENED ---    
Severity: enhancement    
Priority: P3    
Version: 1.8.2   
Target Milestone: ---   
Hardware: All   
OS: other   

Description Ben Litchfield 2003-10-06 17:41:49 UTC
Let's say you have two targets; ejbdoclet and compile.  I would like to always 
run ejbdoclet if called directly.  I would also like to run ejbdoclet when 
compile is called if and only if it has not been run before(or after a clean).

What I wanted to do was this
<target name="ejbdoclet">
...
</target>

<target name="compile" depends="init">
  <available property="ejb-jar.xml.available"
             file="build\META-INF\ejb-jar.xml" />
  <antcall target="ejbdoclet" unless="ejb-jar.xml.available" />
...
</target>

This way if ejbdoclet is called directly it will always get run and if compile 
is called ejbdoclet will only get called if ejb-jar.xml is not available.

I know there are workarounds to this but this enhancement is a lot cleaner.

Ben
Comment 1 Jose Alberto Fernandez 2003-10-06 23:26:18 UTC
Why not just doing:

<target name="compile" depends="init">
 <if>
  <available property="ejb-jar.xml.available"
             file="build\META-INF\ejb-jar.xml" />
  <then>
    <antcall target="ejbdoclet" unless="ejb-jar.xml.available" />
  </then>
 </if>
...
</target>

This to me is 10 times most understandable.
Comment 2 Jose Alberto Fernandez 2003-10-06 23:29:23 UTC
Ups sorry, replace <else> for <then> in the above comment.
Comment 3 Ben Litchfield 2003-10-06 23:30:22 UTC
Where is if/then/else construct documented?
Comment 4 Jose Alberto Fernandez 2003-10-06 23:48:35 UTC
It is part of antcontrib. ONce I started using this task my buildfiles became
10 times more readable. And much fewer temporary properties required to 
control the build.

Hope it is helpful.
Comment 5 Sebb 2011-02-14 09:09:14 UTC
Seems to me that adding if/unless attributes to antcall would still be useful.

AFAICT, the only work-round when using standard Ant (1.8.2) is to add the if/unless to the antcall target,