@Mojo(name="antlr4",
defaultPhase=GENERATE_SOURCES,
requiresDependencyResolution=COMPILE,
requiresProject=true)
public class Antlr4Mojo
extends org.apache.maven.plugin.AbstractMojo
*.g4 and transforms them into Java
source files.| Modifier and Type | Class and Description |
|---|---|
private class |
Antlr4Mojo.CustomTool |
| Modifier and Type | Field and 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.
|
private org.sonatype.plexus.build.incremental.BuildContext |
buildContext |
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.
|
private boolean |
generateTestSources
Specifies whether sources are added to the
compile or
test scope. |
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
|
private java.io.File |
libDirectory
Specify location of imported grammars and tokens files.
|
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.
|
private java.io.File |
outputDirectory
Specify output directory where the Java files are generated.
|
protected java.lang.String |
outputEncoding
specify output file encoding; defaults to source encoding
|
protected org.apache.maven.project.MavenProject |
project
The current Maven project.
|
private java.io.File |
sourceDirectory
The directory where the ANTLR grammar files (
*.g4) are located. |
private java.io.File |
statusDirectory
The directory where build status information is located.
|
protected 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.
|
| Constructor and Description |
|---|
Antlr4Mojo() |
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
addSourceRoot(java.io.File outputDir) |
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.
|
private java.util.List<java.lang.String> |
getCommandArguments() |
private java.io.File |
getDependenciesStatusFile() |
private java.util.Set<java.io.File> |
getGrammarFiles(java.io.File sourceDirectory) |
private java.util.Set<java.io.File> |
getImportFiles(java.io.File sourceDirectory) |
java.util.Set<java.lang.String> |
getIncludesPatterns() |
java.io.File |
getLibDirectory() |
java.io.File |
getOutputDirectory() |
private static java.lang.String |
getPackageName(java.lang.String relativeFolderPath) |
java.io.File |
getSourceDirectory() |
private java.util.List<java.util.List<java.lang.String>> |
processGrammarFiles(java.util.List<java.lang.String> args,
java.util.Set<java.io.File> grammarFiles,
GrammarDependencies dependencies,
java.io.File sourceDirectory) |
private java.lang.String |
validateEncoding(java.lang.String encoding)
Validates the given encoding.
|
@Parameter(property="antlr4.atn",
defaultValue="false")
protected boolean atn
@Parameter(property="project.build.sourceEncoding") protected java.lang.String inputEncoding
@Parameter(property="project.build.sourceEncoding") protected java.lang.String outputEncoding
@Parameter(property="antlr4.listener",
defaultValue="true")
protected boolean listener
@Parameter(property="antlr4.visitor",
defaultValue="false")
protected boolean visitor
@Parameter(property="antlr4.treatWarningsAsErrors",
defaultValue="false")
protected boolean treatWarningsAsErrors
@Parameter(property="antlr4.forceATN",
defaultValue="false")
protected boolean forceATN
@Parameter protected java.util.Map<java.lang.String,java.lang.String> options
-D<option>=<value> syntax.@Parameter protected java.util.List<java.lang.String> arguments
@Parameter protected java.util.Set<java.lang.String> includes
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.
@Parameter protected java.util.Set<java.lang.String> excludes
@Parameter(property="project",
required=true,
readonly=true)
protected org.apache.maven.project.MavenProject project
@Parameter(property="antlr4.generateTestSources",
defaultValue="false")
private boolean generateTestSources
compile or
test scope.@Parameter(defaultValue="${basedir}/src/main/antlr4")
private java.io.File sourceDirectory
*.g4) are located.@Parameter(defaultValue="${project.build.directory}/generated-sources/antlr4")
private java.io.File outputDirectory
@Parameter(defaultValue="${basedir}/src/main/antlr4/imports")
private java.io.File libDirectory
@Parameter(defaultValue="${project.build.directory}/maven-status/antlr4",
readonly=true)
private java.io.File statusDirectory
@Component private org.sonatype.plexus.build.incremental.BuildContext buildContext
protected Tool tool
public java.io.File getSourceDirectory()
public java.io.File getOutputDirectory()
public java.io.File getLibDirectory()
void addSourceRoot(java.io.File outputDir)
public void execute()
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.plugin.MojoFailureException
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 4 Tool
cannot be createdprivate java.util.List<java.lang.String> getCommandArguments()
private java.util.List<java.util.List<java.lang.String>> processGrammarFiles(java.util.List<java.lang.String> args,
java.util.Set<java.io.File> grammarFiles,
GrammarDependencies dependencies,
java.io.File sourceDirectory)
throws org.codehaus.plexus.compiler.util.scan.InclusionScanException,
java.io.IOException
sourceDirectory - org.codehaus.plexus.compiler.util.scan.InclusionScanExceptionjava.io.IOExceptionprivate java.util.Set<java.io.File> getImportFiles(java.io.File sourceDirectory)
throws org.codehaus.plexus.compiler.util.scan.InclusionScanException
org.codehaus.plexus.compiler.util.scan.InclusionScanExceptionprivate java.util.Set<java.io.File> getGrammarFiles(java.io.File sourceDirectory)
throws org.codehaus.plexus.compiler.util.scan.InclusionScanException
org.codehaus.plexus.compiler.util.scan.InclusionScanExceptionprivate static java.lang.String getPackageName(java.lang.String relativeFolderPath)
public java.util.Set<java.lang.String> getIncludesPatterns()
private java.io.File getDependenciesStatusFile()
private java.lang.String validateEncoding(java.lang.String encoding)
null was provided, returns the platform default encoding.