ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cyril Sagan <>
Subject RE: Returning properties
Date Wed, 02 Jan 2008 22:02:52 GMT
Troy - You're having *exactly* the same problem I had three weeks ago.
Here's the full thread from suggestions I got:

The best solution I came up with was to use ant-contrib's <antcallback/>, it can take
a list of properties to return values back to the calling context.

I think you'll want something like:
        <antcallback target="check-up-to-date" return="foo-up-to-date" />

The one disadvantage of <antcallback/> vs. <antcall/> is that <antcallback/>
does not support multiple nested <target name=""/> like <antcall/> does (in 1.7
at least).  This isn't a huge problem, but caused me to introduce more wrapper targets.  Not
sure if this will be an issue for you.

Hope this helps.


-----Original Message-----
From: Daniels, Troy (US SSA) []
Sent: Wednesday, January 02, 2008 4:08 PM
Subject: Returning properties

I have a pattern that is repeated several times, so I'm trying to
extract it into separate tasks in a common build file.  I think I'm
running into problems because I'm trying to treat ant more like a
functional language than it is.

In several places, I have targets that look like this

<target name="generate-foo" depends="check-foo-up-to-date"
   <do-generation param="foo">
      <stuff value="foo" />

<target name="check-foo-up-to-date">
          <!-- several srcfileset and targetfileset -->
            <targetfilelist dir="." files="foo-test-file" />
        <available file="foo-test-file" property="foo-up-to-date"/>

When ant tries to run generate-foo, it first runs check-foo-up-to-date,
which sets foo-up-to-date if foo is up to date.  If foo is up to date,
the unless parameter means the generate-foo target isn't run and all is

If I try to factor out the common parts, there are a few things that
need to be parameterized, which prevents me from calling them with a
simple depends attribute.  Instead, I'm using antcall and the new
targets look like

<target name="generate-foo" depends="check-foo-up-to-date"
   <antcall target="generate">
       <param name="name" value="foo"/>

<target name="check-foo-up-to-date">
   <antcall target="check-up-to-date">
       <param name="file" value="foo-test-file"/>
       <param name="property" value="foo-up-to-date"/>

with generate and check-up-to-date being the new, generic tasks.  This
appears to work, except that foo-up-to-date doesn't get updated in the
original project, only the project associated with the antcall.  Is
there a good way to get the property back to the original project?  I
could do it with files and available, but I'd like something simple to
put into the multiple copies of check-*-up-to-date.


To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message