Fork me on GitHub

JJTree Examples

If you want to use JavaCC in combination with JJTree, simply copy the following snippet into your POM and adjust the goal configuration where the default values do not fit your needs. A list of all configuration options can be seen on the jjtree-javacc goal page.

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>javacc-maven-plugin</artifactId>
        <version>3.0.1</version>
        <executions>
          <execution>
            <id>jjtree-javacc</id>
            <goals>
              <goal>jjtree-javacc</goal>
            </goals>
            <configuration>
              <!-- options for JJTree and JavaCC go here -->
            </configuration>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
    ...
  </build>
  ...
</project>

If you know older versions of the plugin you might be glad to notice that you no longer need to setup two executions to have JJTree and JavaCC run in a pipeline. The jjtree-javacc goal automatically runs both tools.

Once the plugin is properly configured, you can generate the parser along with the tree nodes files by executing the generate-sources lifecycle phase:

mvn generate-sources

Alternatively, you can invoke the jjtree-javacc goal directly from the command line, i.e. without having any other goals run that might be bound to lifecycle phases of your build:

mvn javacc:jjtree-javacc

Note: If you want to use the later call you need to put the <configuration> element directly into the <plugin> element. That is because the configuration inside the <execution> element only applies if the goal is run as part of a lifecycle phase.