Bug 23629 - Allow antcall to have if/unless like target does.
Summary: Allow antcall to have if/unless like target does.
Status: REOPENED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.8.2
Hardware: All other
: P3 enhancement with 1 vote (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-06 17:41 UTC by Ben Litchfield
Modified: 2011-02-14 09:09 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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,