ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: TimeStamp dependent target execution
Date Thu, 06 Jul 2000 18:11:16 GMT

The feel I've gotten over the past couple of months is that many of the
main developers on this project don't want Ant to become another programing
language with all the attendant "if/else", "while", etc. constructs and
complexities.  To that end, they are trying to encourage people to write
very declarative build files, rather than conditional ones.  The
conditional parts of the builds should happen inside a task, so the task
only does what it has to and no more.  So we get the statements like "write
your own task and do it yourself."  They feel, and not unjustly, that
clarity and simplicity outweigh the advantages offered by adding all the
trappings of a full blow language.

I can't say that I've always agreed with every decision the commiters have
made, but they are usually willing to discuss the rationale behind their
decisions.  If you are convincing enough, they will even change their minds
if it helps the overall goals of the project.  And they are trying to stick
to their guns, to keep things clean and simple.  For that, I give them a

Glenn McAllister
TID - Software Developer - VisualAge for Java
IBM Toronto Lab, (416) 448-3805
"An approximate answer to the right question is better than the
right answer to the wrong question." - John W. Tukey

Please respond to

Subject:        TimeStamp dependent target execution


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.
<?xml version="1.0" encoding="UTF-8"?>
<project name="Java2Prolog" default="jar" basedir=".">

        <target name="init">
               <taskdef        name="obsolete"


        <target name="jar" depends="compile">
               <jar        jarfile="j2p.jar"

        <target name="compile" depends="jj">
               <javac srcdir="Source" destdir="Class"/>

        <target name="jjdoc_init" depends="init">
               <obsolete        property="run.jjdoc"


        <target name="jjdoc" depends="jj,jjdoc_init" if ="run.jjdoc">
               <java        classname="COM.sun.labs.jjdoc.JJDocMain"


        <target name="jj_init" depends="init">
               <obsolete        property="run.jj"

        <target name="jj" depends="jjt,jj_init" if="run.jj">
               <java        classname="COM.sun.labs.javacc.Main"

args="-OUTPUT_DIRECTORY=Source/ca/sfu/cs/mas/j2p/parser java.jj"

        <target name="jjt_init" depends="init">
               <obsolete        property="run.jjt"

        <target name="jjt" depends="jjt_init" if="run.jjt">
               <java        classname="COM.sun.labs.jjtree.Main"

args="-OUTPUT_DIRECTORY=Source/ca/sfu/cs/mas/j2p/parser java.jjt"
               <rename        src="Source/ca/sfu/cs/mas/j2p/parser/java.jj"

        <target name="javadoc" depends="jjdoc">
               <javadoc        sourcepath="Source"

                               doctitle="Java2Prolog Parser"

        <target name="test_init" depends="init">
               <obsolete        property="run.test"

        <target name="test" depends="jar,test_init" if="run.test">
               <exec dir="." command="java -jar j2p.jar"/>

        <target name="archive" depends="init">


(Embedded image moved to file: pic23938.pcx)
(See attached file: C.gif)
(Embedded image moved to file: pic14558.pcx)
(See attached file:

View raw message