ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knuplesch, Juergen" <Juergen.Knuple...@icongmbh.de>
Subject AW: Conditional target problem
Date Wed, 18 Aug 2010 11:08:04 GMT
I use the <if> from ant-contrib combined with antcall or antcallback to have more flexibility
on calling targets.

I use properties like ${nocvs} to not use CVS, even when the target is executed (again using
<if> or unless)

 

I have unless properties for CVS, junit, javadoc, compile .....

 

In your case:

    <target name="checkout-sources" depends="other stuff" unless="nocvs">

        <!-- takes several minutes -->

 

In "other stuff" you have to introduce other unless properties probably.

 

Now you run

ant -Drelease.number=... -Dnocvs=true target1" 

 

whil you run target2 this way

 

ant -Drelease.number=... target2" 

 

 

-----Urspr√ľngliche Nachricht-----
Von: Niklas Matthies [mailto:ml_ant-user@nmhq.net] 
Gesendet: Mittwoch, 18. August 2010 00:35
An: user@ant.apache.org
Betreff: Conditional target problem

 

We have something like the following (target bodies omitted):

 

    <target name="checkout-sources" depends="other stuff">

        <!-- takes several minutes -->

 

    <target name="determine-release-number"

        depends="checkout-sources" unless="release.number">

        <!-- determines release.number from sources -->

 

    <target name="target1" depends="determine-release-number">

        <!-- needs release.number -->

 

    <target name="target2" depends="checkout-sources, target1">

        <!-- needs sources and target1 -->

 

The problem: "ant -Drelease.number=... target1" causes

checkout-sources (and its dependencies) to be executed although there

is no need for it, as release.number is already defined.

 

We can't put the unless="release.number" on checkout-sources (and its

dependencies) because it would break target2 when release.number is

predefined.

 

We can't make checkout-sources a macro (called both by target2 and by

determine-release-number) because of all its dependencies, and also

because an up-to-date check on it is highly non-trivial, so in the

target2 case it might end up being executed twice. 

 

We _could_ duplicate the body and the dependencies of checkout-sources

into determine-release-number (and remove the latter's dependency on

checkout-sources), but I'd have to do that for quite a number of the

dependencies as well, as they contribute to the expensiveness of

checkout-sources. The result would be a lot of redundancy, effectively

duplicating a dependency subgraph.

 

Is there a way to solve the problem, within a single Ant instance,

without creating redundancies?

 

-- Niklas Matthies

 

---------------------------------------------------------------------

To unsubscribe, e-mail: user-unsubscribe@ant.apache.org

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

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message