ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marius Scurtescu <mar...@multiactive.com>
Subject Re: TimeStamp dependent target execution
Date Fri, 07 Jul 2000 18:16:08 GMT
Stefan Bodewig wrote:
> 
> >>>>> "MS" == Marius Scurtescu <marius@multiactive.com> writes:
> 
>  MS> Hi, Quite a few people new to ANT asked if it is possible to
>  MS> execute a target/task only if some files are obsolete.
> 
> Marius, I'd like to offer you a somewhat different solution to the
> problem, that doesn't use properties or the if attribute of targets
> but still fills your needs (and that of several other people) IMHO.
> 
> You are tackling a very specific but widely used type of task, tasks
> that take source files and transform them into other files. All these
> tasks could be invoked via exec or java (which is just a convenience
> layer on top of exec). What you want is to avoid the transformation if
> the existing destinations are still valid, correct?
> 
> Well, how about a generic transform task? This task would be a
> subclass of Exec - so you could specify what to do, take a list of
> source files (I'd prefer MatchingTask syntax here) and have some means
> of telling for which destination files to look.
> 
> I'm just developing this idea as I type and would love to see others
> jump in so maybe we could make that a useful new task quite fast.
> 
> Taking your jjdoc target for example.
> 
> Your version:
> 
> <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>
> 
> and make that
> 
> <target name="jjdoc" depends="jj">
>   <transform command="java COM.sun.labs.jjdoc.JJDocMain -OUTPUT_FILE=Source/ca/sfu/cs/mas/j2p/parser/doc-files/grammar.html"
>        fork="yes">
>     <src dir=".">
>       <include name="java.jj" />
>     </src>
>     <dest file="Source/ca/sfu/cs/mas/j2p/parser/doc-files/grammar.html" />
>   </transform>
> </target>
> 
> Note how I didn't include java.jj in the command attribute as I expect
> it to be added by transform as java.jj is part of its source file list.
> 
> Both source and dest could be either a single file (attribute file) or
> a list of files via the proven dir+include+exclude pattern (I'd prefer
> Arnout's filesets).
> 
> Starting with what you've implemented in Obsolete this would make the
> transform task a NOP if all destination files exist and no source file
> is newer than the oldest destination file.

This looks very good to me. The only observation would be that automatically
adding the source file to the command line is hazardous. Some programs
require other options/files after the input file name in which case you would
have to insert the input file names somewhere in the middle of the command. Or
they may be some sort of includes used in the input file in which case
not all the input files are specified in the command line.

I would be happy to work on this but I don't have time until mid August.
If no one is pressed to have it sooner then I will pick it from here.

> 
> We could even go wild here and provide some kind of pattern matching
> to find destination files corresponding to source files and run the
> transformation only for specific file, something like
> 
> <transform command="jade -t rtf -d mydocbookstyle.dsssl">
>   <src dir="documentation/docbook">
>     <include name="**/*.sgml" />
>   </src>
>   <dest dir="documentation/generated/rtf">
>     <include name="**/*.rtf" />
>   </dest>
>   <match src="*.sgml" dest="*.rtf" />
>   <!-- like Perl? <match pattern="/(.*)\.sgml/$1\.rtf/" /> -->
> </transform>
> 
> which is supposed to pick up each DocBook file that is newer than the
> previously generated RTF version and run Jade to make a more recent
> version from it.
> 
> The last part (pattern stuff) needs a bit of thought but the first
> implementation (transform + your obsolete semantics) seems to be
> straight forward.

A similar issue as above, how do you pass the input and output file
names to the command? Using a special variable like in make?

The matching mechanism should provide a one-to-one pairing between
the elements of two sets. If the number of elements in the two sets
is not the name or if one-to-one pairing is not possible then the
whole "transform" should fail.

Since the behaviour of this second transform is quite different
from the first one may be a different syntax would help.

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

Mime
View raw message