Class Antlr4Mojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="antlr4",
          defaultPhase=GENERATE_SOURCES,
          requiresDependencyResolution=COMPILE,
          requiresProject=true,
          threadSafe=true)
    public class Antlr4Mojo
    extends org.apache.maven.plugin.AbstractMojo
    Parses ANTLR 4 grammar files *.g4 and transforms them into Java source files.
    Author:
    Sam Harwell
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.List<java.lang.String> arguments
      A list of additional command line arguments to pass to the ANTLR tool.
      protected boolean atn
      If set to true then the ANTLR tool will generate a description of the ATN for each rule in Dot format.
      protected java.util.Set<java.lang.String> excludes
      A set of Ant-like exclusion patterns used to prevent certain files from being processed.
      protected boolean forceATN
      Use the ATN simulator for all predictions.
      protected java.util.Set<java.lang.String> includes
      Provides an explicit list of all the grammars that should be included in the generate phase of the plugin.
      protected java.lang.String inputEncoding
      specify grammar file encoding; e.g., euc-jp
      protected boolean listener
      Generate parse tree listener interface and base class.
      protected java.util.Map<java.lang.String,​java.lang.String> options
      A list of grammar options to explicitly specify to the tool.
      protected java.lang.String outputEncoding
      specify output file encoding; defaults to source encoding
      protected org.apache.maven.project.MavenProject project
      The current Maven project.
      protected org.antlr.v4.Tool tool
      An instance of the ANTLR tool build
      protected boolean treatWarningsAsErrors
      Treat warnings as errors.
      protected boolean visitor
      Generate parse tree visitor interface and base class.
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Constructor Summary

      Constructors 
      Constructor Description
      Antlr4Mojo()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void execute()
      The main entry point for this Mojo, it is responsible for converting ANTLR 4.x grammars into the target language specified by the grammar.
      java.util.Set<java.lang.String> getIncludesPatterns()  
      java.io.File getLibDirectory()  
      java.io.File getOutputDirectory()  
      java.io.File getSourceDirectory()  
      • Methods inherited from class org.apache.maven.plugin.AbstractMojo

        getLog, getPluginContext, setLog, setPluginContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • atn

        @Parameter(property="antlr4.atn",
                   defaultValue="false")
        protected boolean atn
        If set to true then the ANTLR tool will generate a description of the ATN for each rule in Dot format.
      • inputEncoding

        @Parameter(property="project.build.sourceEncoding")
        protected java.lang.String inputEncoding
        specify grammar file encoding; e.g., euc-jp
      • outputEncoding

        @Parameter(property="project.build.sourceEncoding")
        protected java.lang.String outputEncoding
        specify output file encoding; defaults to source encoding
      • listener

        @Parameter(property="antlr4.listener",
                   defaultValue="true")
        protected boolean listener
        Generate parse tree listener interface and base class.
      • visitor

        @Parameter(property="antlr4.visitor",
                   defaultValue="false")
        protected boolean visitor
        Generate parse tree visitor interface and base class.
      • treatWarningsAsErrors

        @Parameter(property="antlr4.treatWarningsAsErrors",
                   defaultValue="false")
        protected boolean treatWarningsAsErrors
        Treat warnings as errors.
      • forceATN

        @Parameter(property="antlr4.forceATN",
                   defaultValue="false")
        protected boolean forceATN
        Use the ATN simulator for all predictions.
      • options

        @Parameter
        protected java.util.Map<java.lang.String,​java.lang.String> options
        A list of grammar options to explicitly specify to the tool. These options are passed to the tool using the -D<option>=<value> syntax.
      • arguments

        @Parameter
        protected java.util.List<java.lang.String> arguments
        A list of additional command line arguments to pass to the ANTLR tool.
      • includes

        @Parameter
        protected java.util.Set<java.lang.String> includes
        Provides an explicit list of all the grammars that should be included in the generate phase of the plugin. Note that the plugin is smart enough to realize that imported grammars should be included but not acted upon directly by the ANTLR Tool.

        A set of Ant-like inclusion patterns used to select files from the source directory for processing. By default, the pattern **/*.g4 is used to select grammar files.

      • excludes

        @Parameter
        protected java.util.Set<java.lang.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.
      • project

        @Parameter(property="project",
                   required=true,
                   readonly=true)
        protected org.apache.maven.project.MavenProject project
        The current Maven project.
      • tool

        protected org.antlr.v4.Tool tool
        An instance of the ANTLR tool build
    • Constructor Detail

      • Antlr4Mojo

        public Antlr4Mojo()
    • Method Detail

      • getSourceDirectory

        public java.io.File getSourceDirectory()
      • getOutputDirectory

        public java.io.File getOutputDirectory()
      • getLibDirectory

        public java.io.File getLibDirectory()
      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        The main entry point for this Mojo, it is responsible for converting ANTLR 4.x grammars into the target language specified by the grammar.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if a configuration or grammar error causes the code generation process to fail
        org.apache.maven.plugin.MojoFailureException - if an instance of the ANTLR 4 Tool cannot be created
      • getIncludesPatterns

        public java.util.Set<java.lang.String> getIncludesPatterns()