ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniels, Troy \(US SSA\)" <troy.dani...@baesystems.com>
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"
unless="foo-up-to-date">
   <do-generation param="foo">
      <stuff value="foo" />
   </do-generation>
</target>

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

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
good.

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"
unless="foo-up-to-date">
   <antcall target="generate">
       <param name="name" value="foo"/>
   </antcall>
</target>

<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"/>
   </antcall>
</target>

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.

Troy

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


Mime
View raw message