ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marius Scurtescu <>
Subject TimeStamp dependent target execution
Date Thu, 06 Jul 2000 16:59:23 GMT

Quite a few people new to ANT asked if it is possible to
execute a target/task only if some files are obsolete.

The standard answer to this is "write your own task and do
it yourself".

While this approach may be somewhat OK for a Java programmer
familiar with the source code of ANT it is not acceptable for
the general user. Even for a dye hard ANT programmer it would
be a waste of time to code the same behavior over and over

I am new to this mailing list and I am not even close to
having a good understanding of ANT's architecture. If there
is a fundamental misunderstanding here it would be nice to
put an explanation in the documentation so people checking
out ANT will know what to expect.

I created a task that will check the time stamps on two
sets of files, one called source and the other destination.
If any of the source files is newer than one of the
destination files or if one of the destination files is
missing then a property is set. Subsequently a target
can be executed only if that property is set (using the
"if" attribute).

I attached the source file called to this
message. Also I attached the build file I am using so
you get an idea of how you are supposed to use it.
The main trick is that you have to execute the "obsolete"
task just before the corresponding target.

There is room for improvement. The comma separated lists of
file names don't accept wild cards at this point. Also more
sophisticated methods of selecting the source and
destination file sets can be imagined.

Using this task is not an elegant solution to the
time stamp problem, it is a hack. It would have been nice
to include it in the original design.


Marius Scurtescu, Software Engineer
Tel: (604) 899-2835 Fax: (604) 899-2899
Multiactive Software Inc.
Attract and retain customers with Multiactive Software --
proud winners of PC WEEK's "Best of COMDEX" award.
View raw message