On 9/10/07, Peter Reilly <[EMAIL PROTECTED]> wrote:
> with current ant it is difficult to do exactly what you want,
> I normally do the following:
> Pick a file that Sablecc allways changes when it
> is run - ${targetdir}/lexer/Lex.java for example.
> Use ant-contrib's outofdate task.
> <ac:outofdate>
> <sourcefiles path="${grammer.file}"/>
> <targetfiles path="${targetdir}/lexer/Lex.java"/>
> <sequential>
> <sablecc grammer="${grammer.file}" targetdir="${targetdir}"/>
> </sequential>
> </ac:outofdate>
>
> Ant 1.7.1 is adding in a "erroronmissingdir" attribute to filesets, this
> means that one can do:
>
> <ac:outofdate>
> <sourcefiles path="${grammer.file}"/>
> <targetfiles>
> <path path="${targetdir}"/>
> <fileset dir=${targetdir}" erroronmissingdir="false"
> includes="**/*.java"/>
> </targetfiles>
> <sequential>
> <sablecc grammer="${grammer.file}" targetdir="${targetdir}"/>
> </sequential>
> </ac:outofdate>
>
> which is more what you want.
If sablecc does not update the targetdir dir (which it may not) the
above will not work, you will need to use <ac:if>,
and this can be used with ant 1.6.5!
<ac:if>
<or>
<not><available file="${targetdir}"/></not>
<ac:outofdate> <!-- only used if ${targerdir} exists -->
<ac:sourcefiles path="x.grammer"/>
<ac:targetfiles>
<fileset dir="${targetdir}" includes="**/*.java"/>
</ac:targetfiles>
</ac:outofdate>
</or>
<then>
<sablecc grammer="${grammer.file}" targetdir="${targetdir}"/>
</then>
</ac:if>
I would make the above into a macro and store it in a macros.xml file
<!-- invoke sable cc if the generated files are outofdate -->
<!-- useage: <mysablecc grammer="grammer file" targetdir="targetdir"/> -->
<macrodef name="mysablecc">
<attribute name="targetdir"/>
<attribute name="grammer"/>
<sequential>
<ac:if>
<or>
<not><available file="@{targetdir}"/></not>
<ac:outofdate>
<ac:sourcefiles path="@{grammer}"/>
<ac:targetfiles>
<fileset dir="@{targetdir}" includes="**/*.java"/>
</ac:targetfiles>
</ac:outofdate>
</or>
<then>
<sablecc grammer="@{grammer}" targetdir="@{targetdir}"/>
</then>
</ac:if>
</sequential>
</macrodef>
Peter
> Peter
>
> On 9/10/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > You can set a property if a file/directory does (not) exist using
> > <available> and <available> in combination with <condition>, <not>.
> >
> > The "changed" files you maybe could check with <condition> and
> > <isfileselected>
> > in combination with <date> selector or <modified> selector.
> >
> >
> > Jan
> >
> > >-----Ursprüngliche Nachricht-----
> > >Von: Lionel van den Berg [mailto:[EMAIL PROTECTED]
> > >Gesendet: Montag, 10. September 2007 00:46
> > >An: [email protected]
> > >Betreff: Ant uptodate?
> > >
> > >Hi all,
> > >
> > >I sent two other emails but I don't think they went through.
> > >
> > >I've tried using the ant uptodate and dependset tasks but
> > >haven't solved my
> > >problem. I've googled, tried heaps of solutions but still
> > >can't do it, so
> > >here is the problem:
> > >
> > >Assume for each of the following we are in a base directory. I have:
> > >
> > >grammar/*.grammar files.
> > >
> > >From a *.grammar file Sablecc will generate .java files (and some .dat
> > >files) in:
> > >
> > >src/*/analysis/
> > >src/*/lexer/
> > >src/*/node/
> > >src/*/parser/
> > >
> > >
> > >When my Ant script is run, src/ may or may not exist.
> > >
> > >What I want to do is just set a property if either src/ does
> > >not exist or
> > >any of the files in any of files in grammar/ have been
> > >modified after any of
> > >the files in the subdirectories of src/.
> > >
> > >Can someone please help me? It seems that this should be fairly simple.
> > >
> > >Thanks
> > >
> > >Lionel.
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]