Hiya... I am using JavaCC for a little project I play with on the
side (GShell), and I got kinda frustrated with the current javacc-
maven-plugin with some of the fancy build muck I had to do to get it
to work as desired for using jjtree + javacc, like handling class
overrides or one.
Sooo... I whipped up, what I think is a better version... which
currently lives here:
http://svn.apache.org/repos/asf/geronimo/sandbox/gshell/trunk/
javacc-maven-plugin/
This guy lets me do this:
----8<----
<build>
<plugins>
<plugin>
<groupId>org.apache.geronimo.gshell</groupId>
<artifactId>javacc-maven-plugin</artifactId>
<version>1.0-alpha-1-SNAPSHOT</version>
<executions>
<execution>
<id>jjtree</id>
<phase>generate-sources</phase>
<goals>
<goal>jjtree</goal>
</goals>
<configuration>
<grammars>
<directory>${project.basedir}/src/main/
grammar</directory>
<includes>
<include>*.jjt</include>
</includes>
</grammars>
</configuration>
</execution>
<execution>
<id>javacc</id>
<phase>generate-sources</phase>
<goals>
<goal>javacc</goal>
</goals>
<configuration>
<grammars>
<directory>${project.build.directory}/
generated-sources/jjtree</directory>
<includes>
<include>*.jj</include>
</includes>
</grammars>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
---->8----
And that is all that is needed to handle generating a javacc grammar
from a jjtree grammar, and the parser from the generated javacc
bits... and it will handle overridden classes defined by the
project. Before I had to hack in some antrun to delete classes,
etc... which was no fun to maintain. The latest javacc-maven-plugin
tried to solve this by forcing all overridden classes to be in in
some other directory, but that doen't work so well when using jjtree
+ javacc, not to mention that I like to have my java source in the
proper place, under src/main/java.
It works, by generating things in the normal way, into a temp dir,
then loading each class with QDox (yay QDox!) and then checking to
see if there is source already in the main tree. If not, then it
copies the file to the proper target/generated-sources/* dir. Works
very well, at the slight cost of generating each time, though even
that could be optimized a bit more if needed. I chose to load the
generated source with qdox, since jjtree can put node classes in one
dir which is configurable, but can't seem to configure where some of
the others go... and rather than try to dance around it to figure out
how to tell if an exist classes was already defined, I just load the
bits in QDox and ask it for the classname. QDox works fine for Java
1.4 sources (some problems with Java 5 stuff I believe), but javacc
and jjtree both generate Java 1.4 compatible sources, so all is fine
on that front, even if your project is using Java 5, this will still
work as expected.
Just wondering if anyone else is interested in this enhanced javacc
plugin. It does most of what the current plugin does, 'cept I didn't
implement any support for JTB. And I didn't finish implementing the
option handling for either javacc or jjtree, though that is trivial
to add. I suppose JTB support is easy enough to add too, though...
even though I like the JTB concept, the implementation was far to
immature for me to actually use, so I just kept on with the slightly
more verbose and complex syntax of jjtree.
BTW, this is a Groovy mojo... so if you are interested to see what
one of those looks like you might want to take a peek. Its mostly
like a Java mojo, cept a wee bet less verbose.
Anyways, if folks are interested I can drop this into the Mojo
project and sort out the differences with the current javacc-maven-
plugin, and fix up the docs... or not... either way ;-)
Cheers,
--jason
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email