ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniels, Troy \(US SSA\)" <>
Subject Returning properties
Date Wed, 02 Jan 2008 21:08:19 GMT
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:

View raw message