Package org.antlr.mojo.antlr4
Class Antlr4Mojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.antlr.mojo.antlr4.Antlr4Mojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="antlr4", defaultPhase=GENERATE_SOURCES, requiresDependencyResolution=COMPILE, requiresProject=true) public class Antlr4Mojo extends org.apache.maven.plugin.AbstractMojoParses ANTLR 4 grammar files*.g4and transforms them into Java source files.- Author:
- Sam Harwell
-
-
Field Summary
Fields Modifier and Type Field Description protected List<String>argumentsA list of additional command line arguments to pass to the ANTLR tool.protected booleanatnIf set to true then the ANTLR tool will generate a description of the ATN for each rule in Dot format.protected Set<String>excludesA set of Ant-like exclusion patterns used to prevent certain files from being processed.protected booleanforceATNUse the ATN simulator for all predictions.protected Set<String>includesProvides an explicit list of all the grammars that should be included in the generate phase of the plugin.protected StringinputEncodingspecify grammar file encoding; e.g., euc-jpprotected booleanlistenerGenerate parse tree listener interface and base class.protected Map<String,String>optionsA list of grammar options to explicitly specify to the tool.protected StringoutputEncodingspecify output file encoding; defaults to source encodingprotected org.apache.maven.project.MavenProjectprojectThe current Maven project.protected TooltoolAn instance of the ANTLR tool buildprotected booleantreatWarningsAsErrorsTreat warnings as errors.protected booleanvisitorGenerate parse tree visitor interface and base class.
-
Constructor Summary
Constructors Constructor Description Antlr4Mojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()The main entry point for this Mojo, it is responsible for converting ANTLR 4.x grammars into the target language specified by the grammar.Set<String>getIncludesPatterns()FilegetLibDirectory()FilegetOutputDirectory()FilegetSourceDirectory()
-
-
-
Field Detail
-
atn
@Parameter(property="antlr4.atn", defaultValue="false") protected boolean atnIf 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 String inputEncoding
specify grammar file encoding; e.g., euc-jp
-
outputEncoding
@Parameter(property="project.build.sourceEncoding") protected String outputEncoding
specify output file encoding; defaults to source encoding
-
listener
@Parameter(property="antlr4.listener", defaultValue="true") protected boolean listenerGenerate parse tree listener interface and base class.
-
visitor
@Parameter(property="antlr4.visitor", defaultValue="false") protected boolean visitorGenerate parse tree visitor interface and base class.
-
treatWarningsAsErrors
@Parameter(property="antlr4.treatWarningsAsErrors", defaultValue="false") protected boolean treatWarningsAsErrorsTreat warnings as errors.
-
forceATN
@Parameter(property="antlr4.forceATN", defaultValue="false") protected boolean forceATNUse the ATN simulator for all predictions.
-
options
@Parameter protected Map<String,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 List<String> arguments
A list of additional command line arguments to pass to the ANTLR tool.
-
includes
@Parameter protected Set<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
**/*.g4is used to select grammar files.
-
excludes
@Parameter protected Set<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 projectThe current Maven project.
-
tool
protected Tool tool
An instance of the ANTLR tool build
-
-
Method Detail
-
getSourceDirectory
public File getSourceDirectory()
-
getOutputDirectory
public File getOutputDirectory()
-
getLibDirectory
public File getLibDirectory()
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionThe 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 failorg.apache.maven.plugin.MojoFailureException- if an instance of the ANTLR 4Toolcannot be created
-
-