You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Marius Scurtescu <ma...@multiactive.com> on 2000/06/25 21:38:04 UTC
JavaCC tasks for ANT
Hi all,
I am writing you because while checking the ANT mailing
list archives I saw that you were interested in JavaCC
related tasks for ANT.
Since running JJTree and JavaCC are time consuming my
main problem is running them only if the source grammar
file was touched. While you can get this quite easily
with a classic make utility, there is no support for
this in ANT. Do you have a solution for this?
The way I run JavaCC is by using a "java" task to
run the main applications directly:
<target name="jjdoc" depends="jj">
<java classname="COM.sun.labs.jjdoc.JJDocMain" args="-OUTPUT_FILE=Doc/grammar.html java.jj" fork="yes"/>
</target>
<target name="jj" depends="jjt">
<java classname="COM.sun.labs.javacc.Main" args="-OUTPUT_DIRECTORY=Source/parser java.jj" fork="yes"/>
</target>
<target name="jjt">
<java classname="COM.sun.labs.jjtree.Main" args="-OUTPUT_DIRECTORY=Source/parser java.jjt" fork="yes"/>
<rename src="Source/parser/java.jj" dest="java.jj"/>
</target>
This will work assuming that JavaCC.zip is in your class path.
To solve the time stamp based conditional task run I was
thinking to create a generic task that will add a property
based on time stamp comparison between two sets of files, the
inputs and outputs to some other task. This other task/targets
could then be run only if this property is set.
Please let me know if all this makes sense in your opinion.
Cheers,
Marius
Re: JavaCC tasks for ANT
Posted by Thomas Haas <th...@softwired-inc.com>.
Attached please find our implemenmtation of a JavaCC task.
Our build file looks like the following:
<target name="javacc">
<mkdir dir="${tool.metamata.work}"/>
<javacc
target="${src.dir}/ch/softwired/.../Scanner.jj"
meatamatahome="${tool.metamata.home}"
workingdir="${tool.metamata.work}"
<userclasspath>
<element location="${src.java}"/>
<element location="${lib.metamata}"/>
</userclasspath>
</javacc>
<javacc>
...
</javacc>
<deltree dir="${tool.metamata.work}"/>
</targ>
The variables tool.metamata.home, tool.metamata.workdir and lib.metamata
are set like the following:
tool.metamata.home: directory where metamata is installed with the
following contents:
freebies.key
metamata.license
lib/JavaCC.zip
lib/freebies.jar
lib/metamata.jar
lib/metamatadebug.jar
tool.metamata.workdir: some directory created and erased used by javacc
to put temp. files in.
lib.metamata: points to the jar ${tool.metamata.home}/lib/metamata.jar
Features:
javacc cleans up some files left behind javacc lik OO393.class and other
stuff.
javacc only rebuilds the .java files if the .jj files are newer
Todo:
Use file matching or multiple file arguments
This is in production for 3 months now at our site.
Feedback welcomed.
- tom
marius@multiactive.com (Marius Scurtescu) wrote:
>
> Hi all,
>
> I am writing you because while checking the ANT mailing
> list archives I saw that you were interested in JavaCC
> related tasks for ANT.
>
> Since running JJTree and JavaCC are time consuming my
> main problem is running them only if the source grammar
> file was touched. While you can get this quite easily
> with a classic make utility, there is no support for
> this in ANT. Do you have a solution for this?
>
> The way I run JavaCC is by using a "java" task to
> run the main applications directly:
>
> <target name="jjdoc" depends="jj">
> <java classname="COM.sun.labs.jjdoc.JJDocMain" args="-OUTPUT_FILE=
Doc/grammar.html java.jj" fork="yes"/>
> </target>
> <target name="jj" depends="jjt">
> <java classname="COM.sun.labs.javacc.Main" args="-OUTPUT_DIRECTORY=
Source/parser java.jj" fork="yes"/>
> </target>
> <target name="jjt">
> <java classname="COM.sun.labs.jjtree.Main" args="-OUTPUT_DIRECTORY=
Source/parser java.jjt" fork="yes"/>
> <rename src="Source/parser/java.jj" dest="java.jj"/>
> </target>
>
> This will work assuming that JavaCC.zip is in your class path.
>
> To solve the time stamp based conditional task run I was
> thinking to create a generic task that will add a property
> based on time stamp comparison between two sets of files, the
> inputs and outputs to some other task. This other task/targets
> could then be run only if this property is set.
>
> Please let me know if all this makes sense in your opinion.
>
> Cheers,
> Marius