Sunday, 4 May 2014

Configuring the JavaCC Maven Plugin for JavaCC 6.1.2 or above

JavaCC 6.1.2 is finally available in Maven Central.

The JavaCC Maven plugin is independently maintained and uses an older version of JavaCC as its default dependency so to make it use JavaCC 6.1.x, use the following configuration in your Maven build.

How to use :

  1. Place your .jj files in the source folder : src/main/javacc
  2. Add the configuration to your plugins section in the maven configuration (see the next section).
  3. Execute "mvn clean generate-sources".

POM Configuration (change 6.1.2 to the latest version if required)

<build>
<plugins>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>javacc-maven-plugin</artifactId>
    <version>2.6</version>
    <executions>
      <execution>
        <goals>
          <goal>javacc</goal>
        </goals>
      </execution>
    </executions>
      <dependencies>
        <dependency>
          <groupId>net.java.dev.javacc</groupId>
          <artifactId>javacc</artifactId>
          <version>6.1.2</version>
        </dependency>
      </dependencies>
  </plugin>
</plugins>
</build>

Eclipse not seeing generated sources?

If you are having trouble with Eclipse not detecting generated classes, take a look at this thread.

Some Projects Using the Maven/JavaCC plugin

For your reference: