Skip to content

tulipcc/tulipcc-maven-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tulipcc-maven-plugin

An updated version of the javacc-maven-plugin. Originally it was JavaCC 6.1.3, than updated to JavaCC 7.0 but in the meantime the underlying code is the ParserGeneratorCC project which is a fork of JavaCC 7.0.3 but with slightly improved code and output quality. The main difference is the removed code compatibility for generating code below Java 1.5 - respective options where removed.
For the rest, the parameters etc. where basically not touched, so it should be a drop-in replacement for the old javacc-maven-plugin 2.6. It requires Java 1.8 or higher and Apache Maven 3.x or higher.

It is licensed under the Apache 2 license.

I'm using it e.g. in ph-css for CSS parsing.

Upgrading from the original plugin

The following list is member-gathered when they update to this plugin and is not comprehensive

  • Requires at least Java 1.5
  • use the constructor with "InputStream, Charset", the one with only "InputStream" throws an Exception
  • change TokenMgrError into TokenMgrException

Maven usage

Example with 3 executions (two javacc and one jjtree-javacc), try with mvn clean process-resources:

    <build>
      ...
      <plugin>
        <groupId>io.github.tulipcc</groupId>
        <artifactId>tulipcc-maven-plugin</artifactId>
        <version>4.1.4</version>
        <executions>
          <execution>
            <id>jjc1</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>javacc</goal>
            </goals>
            <configuration>
              <jdkVersion>1.5</jdkVersion>
              <javadocFriendlyComments>true</javadocFriendlyComments>
              <packageName>org.javacc.parser</packageName>
              <sourceDirectory>src/main/java/org/javacc/parser</sourceDirectory>
              <outputDirectory>${project.build.directory}/generated-sources/javacc1</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>jjt2</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>javacc</goal>
            </goals>
            <configuration>
              <jdkVersion>1.5</jdkVersion>
              <javadocFriendlyComments>true</javadocFriendlyComments>
              <packageName>org.javacc.utils</packageName>
              <sourceDirectory>src/main/java/org/javacc/utils</sourceDirectory>
              <outputDirectory>${project.build.directory}/generated-sources/javacc2</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>jjt1</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>jjtree-javacc</goal>
            </goals>
            <configuration>
              <jdkVersion>1.5</jdkVersion>
              <javadocFriendlyComments>true</javadocFriendlyComments>
              <packageName>org.javacc.parser</packageName>
              <sourceDirectory>src/main/java/org/javacc/jjtree</sourceDirectory>
              <excludes>
                <exclude>**/parser/**</exclude>
              </excludes>
              <outputDirectory>${project.build.directory}/generated-sources/jjtree1</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      ...
    </build>

Supported goals with the respective parameters are:

  • javacc - parses a JavaCC grammar file (*.jj) and transforms it to Java source files. Detailed information about the JavaCC options can be found on the JavaCC website
    • File sourceDirectory - The directory where the JavaCC grammar files (*.jj) are located. Defaults to ${basedir}/src/main/javacc.
    • File outputDirectory - The directory where the parser files generated by JavaCC will be stored. The directory will be registered as a compile source root of the project such that the generated files will participate in later build phases like compiling and packaging. Defaults to ${project.build.directory}/generated-sources/javacc
    • int staleMillis - The granularity in milliseconds of the last modification date for testing whether a source needs recompilation. Defaults to 0
    • String[] includes - A set of Ant-like inclusion patterns used to select files from the source directory for processing. By default, the patterns **/*.jj and **/*.JJ are used to select grammar files.
    • String[] excludes - A set of Ant-like exclusion patterns used to prevent certain files from being processed. By default, this set is empty such that no files are excluded.
  • jjdoc - JJDoc takes a JavaCC parser specification and produces documentation for the BNF grammar. This mojo will search the source directory for all *.jj files and run JJDoc once for each file it finds. Each of these output files, along with an index.html file will be placed in the site directory (target/site/jjdoc), and a link will be created in the "Project Reports" menu of the generated site.
  • jjtree-javacc - preprocesses decorated grammar files (*.jjt) with JJTree and passes the output to JavaCC in order to finally generate a parser with parse tree actions.
  • jtb-javacc - preprocesses ordinary grammar files (*.jtb) with JTB and passes the output to JavaCC in order to finally generate a parser with parse tree actions.

Integration tests

  • To run the integration tests use the following commandline mvn clean install -Dit=true
  • If you have a proxy server in place, edit src/it/settings.xml and add it there
  • When integration tests are run, they create a folder it-local-repo inside this folder. This is the local Maven repository and is safe to be deleted.
  • When running the IT, the files are located in target/it - so check all the build logs there

External links

News and noteworthy

  • v5.0.0 - 2023-10-18
    • Migrated artifact id from com.helger.maven:ph-javacc-maven-plugin to io.github.tulipcc:tulipcc-maven-plugin
    • Support Java 21 (upgraded dependencies)
  • v4.1.5 - 2022-01-10
    • Updated to ParserGeneratorCC 1.1.4
  • v4.1.4 - 2020-05-13
    • Updated to ParserGeneratorCC 1.1.3
  • v4.1.3 - 2019-05-02
    • Updated to ParserGeneratorCC 1.1.2
  • v4.1.2 - 2019-01-28
    • Updated to ParserGeneratorCC 1.1.1 - had an error in the modern templates
  • v4.1.1 - 2018-12-03
    • JJDoc now runs without forking
    • Made plugin threadsafe (see issue #14)
  • v4.1.0 - 2018-10-25
    • Updated to ParserGeneratorCC 1.1.0 - INCOMPATIBLE!
    • Changed PGCC templates - INCOMPATIBLE!
    • Added OUTPUT_ENCODING option
  • v4.0.3 - 2018-03-09
    • Fixed error passing JAVA_TEMPLATE_TYPE option in jjtree-java goal
  • v4.0.2 - 2018-03-09
    • Removed STATIC option - INCOMPATIBLE!
    • Added JAVA_TEMPLATE_TYPE option
  • v4.0.1 - 2018-01-08
    • Updated to ParserGeneratorCC 1.0.2 so that this plugin can be used to build ParserGeneratorCC
    • Minimum JDK version is 1.5
  • v4.0.0 - 2018-01-05
  • v3.0.0 - 2017-11-07
    • Changed minimum requirement to JDK 8
    • Requires Maven 3 for execution
    • Using JavaCC 7.0.3
    • Removed deprecated classes
  • v2.8.2 - 2016-11-19
  • v2.8.1 - 2016-07-13
    • Fixed a problem with the code generation for "modern" Java template

My personal Coding Styleguide | It is appreciated if you star the GitHub project if you like it.