ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Garrick Olson <>
Subject RE: suggestions
Date Thu, 20 Sep 2001 21:11:45 GMT

> > > 2) something that calls one or more targets AFTER a target has
> > > completed.  for example, in my init target, i often have properties
> > > i need to conditionally set, and currently the only way to easily do
> > > that is multiple targets with 'if' attributes.  but, i would still
> > > to ensure that the init is completed first, while still ensuring that
> > > the other conditional-inits are completed immediately following the
> > > target.
> > 
> > Maybe I'm just not fully awake yet this morning, but -- you lost me. The
> > only I know of to start another target before the first one is done is
> > include an <antcall>/<ant> in it, then have additional tasks after that.
> > Eg:
> >   <target name="foo">
> >     <echo message="I'm foo..."/>
> >     <antcall target="bar"/>
> >     <echo message="I'm foo again."/>
> >   </target>
> >   <target name="bar">
> >     <echo message="I'm bar..."/>
> >   </target>
> well, considering all the other problems with variables i've been having
> when using antcall, i was looking for some other solution.  so, i would
> have:
> <target name="foo" depends="before" after="bar">
> ...
> </target>
> so, when this target is invoked, the 'before' target will be invoked
> first, then the 'foo' target is invoked, and then finally (assuming no
> failures) the 'bar' target is invoked.
> this preserves the 'nature' of calling subtargets, and presuming props
> are handled in the same way in the 'after' attribute as they are in the
> 'depends' attribute, the unique behaviour of ant and antcall can be
> ignored.

I have a similar situation with running multiple sets of tests.  Assume I
have the following targets:

<target name="init.tests">
    ...delete and re-create ${testresults.dir}...

<target name="">
    ...generate report for all test results...

I want to be able to call some.tests, other.tests, or all.tests from the
command line and get a test report containing whichever tests executed.  You
cannot use <antcall> within the some.tests and other.tests targets, because
then if you call the all.tests target, the target will be called
twice, with the second call squashing the first call's results.  Here is
what I do:

<target name="some.tests" depends="internal.some.tests,">
<target name="internal.some.tests" depends="init.tests">

<target name="other.tests" depends="internal.other.tests,">
<target name="internal.other.tests" depends="init.tests">

<target name="all.tests" depends="internal.some.tests, internal.other.tests," />

I think it would be much more elegant if there were an "after" or
"postdepends" so I could instead write:

<target name="some.tests" depends="init.tests" postdepends="">

<target name="other.tests" depends="init.tests" postdepends="">

<target name="all.tests" depends="some.tests, other.tests" />

Note that the behavior here is *not* to simply execute another target
immediately (as an <antcall> would do).  When I call all.tests, the target
order should be:

other.tests   (note: executed only once, and immediately after the last
target to have a postdepends="")

Confidential Information. This email is for intended recipient only.

View raw message