ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Barry Pape" <bp...@netspend.com>
Subject RE: How to conditionally run a group of targets?
Date Fri, 14 Dec 2007 15:44:12 GMT
Someone recently mentioned the antcallback task which is part of
ant-contrib.  It's the same as antcall but allows properties set in the
called target to be available for use in the calling target.  Maybe that
would work for you.
http://antelope.tigris.org/nonav/docs/manual/bk03ch20.html

Barry

-----Original Message-----
From: Cyril Sagan [mailto:Cyril.Sagan@sas.com] 
Sent: Friday, December 14, 2007 8:30 AM
To: Ant Users List
Subject: RE: How to conditionally run a group of targets?

Dmitri - Thanks for the response, but this does not work.

The problem is that state (properties) set by the target of an <antcall>
will not be available to the calling environment.

I'm still looking for an elegant solution.

--Cyril

________________________________________
From: Dmitri Farafonov [farafonov@gmail.com]
Sent: Thursday, December 13, 2007 8:07 PM
To: Ant Users List
Subject: Re: How to conditionally run a group of targets?

You can use "if" from ant-contrib:
http://ant-contrib.sourceforge.net/tasks/tasks/if.html
<if><isset property="doit"/>
    <then><antcall>....</antcall></then>
</if>
All possible "if" conditions are here:
http://ant.apache.org/manual/CoreTasks/conditions.html

Hope it helps,
Dmitri.

Cyril Sagan wrote:
> Our build script needs to run an arbitrary *group* of targets based on
> a single property.  Can you help me find a clean way to do this?
>
> Here's an "almost solution" which illustrates what I'd like to
> accomplish:
>
>     <target name="all" depends="init, decide_to_run_group, wrapper" />
>
>     <target name="decide_to_run_group">
>         <condition property="doit" value="true">
>             <some-boolean-test/>
>         </condition>
>     </target>
>
>     <target name="wrapper" if="doit">
>         <antcall>
>             <target name="A" />
>             <target name="B" />
>             <target name="C" />
>             <target name="D" />
>         </antcall>
>     </target>
>
>
> This does not work.  The problem is that any properties set in the
> <antcall>'d targets will not be visible in the calling environment.
> Targets A,B,C,etc -- not all of which I control, so I cannot
> restructure -- may have side effects, setting state in properties that
> I need to have access to.
>
> Regarding the "<antcall> almost solution", I see that there are ways
> to pass properties "down to" <antcall>, but I do not know of a clean
> way to "pass back".  I found a year+ old question on ant-dev asking
> about this, but never saw an answer.
>
> In any case, we aren't set on using (enhancing?) <antcall>, it was
> just close to a solution.
>
> Goal is to group the set of targets.  I'm hoping to find a solution
> less awkward than this:
>     <target name="A" if="doit" ... />
>     <target name="B" if="doit" ... />
>     <target name="C" if="doit" ... />
>     <target name="D" if="doit" ... />
>
> Thanks for any suggestions.
>
> --Cyril
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


-----------------------------------------
Confidentiality Notice!
This electronic transmission and any attached documents or other
writings are confidential and are for the sole use of the intended
recipient(s) identified above. This message may contain information
that is privileged, confidential or otherwise protected from
disclosure under applicable law. If the receiver of this
information is not the intended recipient, or the employee, or
agent responsible for delivering the information to the intended
recipient, you are hereby notified that any use, reading,
dissemination, distribution, copying or storage of this information
is strictly prohibited. If you have received this information in
error, please notify the sender by return email and delete the
electronic transmission, including all attachments from your
system.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message