ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@bost.de>
Subject Re: TimeStamp dependent target execution
Date Fri, 07 Jul 2000 10:16:50 GMT
>>>>> "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.

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.

Comments?

Stefan

Mime
View raw message