ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gle...@ca.ibm.com
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
+1.

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 ant-dev@jakarta.apache.org

To:        ant-dev@jakarta.apache.org
cc:
Subject:        TimeStamp dependent target execution



[IMAGE]
Hi,

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

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 Obsolete.java 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.

Cheers,
Marius


--
------------------
Marius Scurtescu, Software Engineer
Tel: (604) 899-2835 Fax: (604) 899-2899
mailto:marius@multiactive.com
Multiactive Software Inc. http://www.multiactive.com
------------------
Attract and retain customers with Multiactive Software --
proud winners of PC WEEK's "Best of COMDEX" award.
------------------
[IMAGE]
[IMAGE]
<?xml version="1.0" encoding="UTF-8"?>
<project name="Java2Prolog" default="jar" basedir=".">

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

classname="org.apache.tools.ant.taskdefs.optional.Obsolete"
               />
       </target>

        <target name="jar" depends="compile">
               <jar        jarfile="j2p.jar"
                       basedir="./Class"
                       manifest="Manifest.mf"
               />
       </target>

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

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

destination="Source/ca/sfu/cs/mas/j2p/parser/doc-files/grammar.html"
               />
       </target>

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

args="-OUTPUT_FILE=Source/ca/sfu/cs/mas/j2p/parser/doc-files/grammar.html
java.jj"
                       fork="yes"
               />
       </target>

        <target name="jj_init" depends="init">
               <obsolete        property="run.jj"
                               source="java.jj"
destination="Source/ca/sfu/cs/mas/j2p/parser/Java2Prolog.java"
               />
       </target>

        <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"
                       fork="yes"
               />
       </target>

        <target name="jjt_init" depends="init">
               <obsolete        property="run.jjt"
                               source="java.jjt"
                               destination="java.jj"
               />
       </target>

        <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"
                       fork="yes"
               />
               <rename        src="Source/ca/sfu/cs/mas/j2p/parser/java.jj"
                       dest="java.jj"
               />
       </target>

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

packagenames="ca.sfu.cs.mas.j2p.helper.*,ca.sfu.cs.mas.j2p.parser.*"
                               private="Yes"
                               overview="Source/overview.html"
                               author="Yes"
                               version="Yes"
                               use="Yes"
                               windowtitle="Java2Prolog"
                               doctitle="Java2Prolog Parser"
               />
       </target>

        <target name="test_init" depends="init">
               <obsolete        property="run.test"
                               source="test.java,j2p.jar"
                               destination="test.pro"
               />
       </target>

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

        <target name="archive" depends="init">
               <zip
zipfile="E:\ProjectArchive\a${DSTAMP}_${TSTAMP}.zip"
                       basedir=".."
                       excludes="backup/**,J2P/Class/**,J2P/Doc/**"
               />
       </target>

</project>



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

Mime
View raw message