Java Mailing List Archive

Apache Ant Archive

» Ant Users List
» Ant Developers List
Conditional dependencies

Conditional dependencies

2007-03-19       - By Murray, Mike
Reply:     1     2     3     4     5     6     7     8     9  

I sympathize with your frustration.  I don't know of a better way.  It
would be nice if there was a -nodeps option.

Here's what I do, and I have many targets:

<target name="dist"   depends="jar,dist.only">
<target name="jar"   depends="compile,jar.only">

<target name="dist.only" unless="dist.skip">
<target name="jar.only"   unless="jar.skip">

-----Original Message-----
From: Brown, Carlton [mailto:Carlton.Brown@(protected)]
Sent: Monday, March 19, 2007 5:21 PM
To: Ant Users List
Subject: Conditional dependencies

There's a build behavior pattern I keep hitting, but I don't know how to
resolve in Ant.   How can I specify a dependency chain among targets
such that the dependency chain can be "short-circulted" with a property
that prevents all the others from being resolved?

For example, lets say I have this linear dependency chain:
dist -> jar -> compile -> clean

Obviously the target declarations will be:
<target name="dist" depends="jar">
<target name="jar" depends="compile">

In most cases, I want to run the whole graph.   But sometimes I just
want to run dist and jar, short-circuiting the dependency graph before
"compile", preventing it or any of its dependencies from executing.  I'm
not even interested in letting ant cycle through the tasks and determine
that they don't need to be done.

Of course my first thought was to try a condition on the target:
<target name="compile" unless="no.compile">

Which doesn't do what I need.. it skips the "compile" step, but it won't
skip compile's dependencies ("clean" still runs).

Next I pondered creating these discrete tasks as independent tasks, and
then composing my dependency chain of wrapper tasks:
<target name="dist" depends="jar">
  <antcall target="dist-impl"/>

<target name="dist-impl">
  <!-- no dependencies, just the facts ma'am -->
    <tarfileset blah blah blah/>

Is that the only choice?  My actual dependency chain is as deep as 6 or
7 levels in some places.  Creating a parallel sham dependency chain is
teh suck.  Isn't there a better way?



The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential, proprietary, and/or
privileged material. Any review, retransmission, dissemination or other
use of, or taking of any action in reliance upon this information by
persons or entities other than the intended recipient is prohibited. If
you received this in error, please contact the sender and delete the
material from all computers. GA623

To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 - Jax Systems, LLC, U.S.A.