Package org.codehaus.mojo.antlr
Class AbstractAntlrMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.mojo.antlr.AbstractAntlrMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
,Environment
- Direct Known Subclasses:
AntlrHtmlReport
,AntlrPlugin
public abstract class AbstractAntlrMojo
extends org.apache.maven.plugin.AbstractMojo
implements Environment
Base class with majority of Antlr functionalities.
- Version:
- $Id: AbstractAntlrMojo.java 13111 2010-11-16 22:16:36Z pgier $
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
Launch the ParseView debugger upon parser invocation.private boolean
Generate a text file from your grammar with a lot of debugging info.protected Grammar[]
Grammar list presents in thesourceDirectory
directory.protected String
Comma separated grammar file names or grammar pattern file names present in thesourceDirectory
directory.protected File
Specifies the destination directory where Antlr should generate files.protected org.apache.maven.project.MavenProject
The Maven Project Objectprivate org.apache.maven.project.MavenProjectHelper
The maven project's helper.protected File
Specifies the Antlr directory containing grammar files.private boolean
Have all rules call traceIn/traceOut.private boolean
Have lexer rules call traceIn/traceOut.private boolean
Have parser rules call traceIn/traceOut.private boolean
Have tree rules call traceIn/traceOut.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static void
Convenience method to add an argumentprotected abstract void
Add arguments to be included in Antlr callprotected void
private void
executeAntlrInIsolatedClassLoader
(String[] args, org.apache.maven.artifact.Artifact antlrArtifact) private String
generateClasspathForProcessSpawning
(org.apache.maven.artifact.Artifact antlrArtifact) private File
getGeneratedFile
(String grammar, File outputDir) private Grammar[]
Get the list of all grammars to be compiled.protected final org.apache.maven.artifact.Artifact
protected void
performGeneration
(GenerationPlan plan, org.apache.maven.artifact.Artifact antlrArtifact) private void
grammars or grammarDefs parameters is requiredMethods 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
Methods inherited from interface org.codehaus.mojo.antlr.Environment
getLog
Methods inherited from interface org.apache.maven.plugin.Mojo
execute
-
Field Details
-
sourceDirectory
Specifies the Antlr directory containing grammar files. -
project
@Parameter(property="project", readonly=true) protected org.apache.maven.project.MavenProject projectThe Maven Project Object -
projectHelper
@Component(role=org.apache.maven.project.MavenProjectHelper.class) private org.apache.maven.project.MavenProjectHelper projectHelperThe maven project's helper. -
outputDirectory
@Parameter(defaultValue="${project.build.directory}/generated-sources/antlr") protected File outputDirectorySpecifies the destination directory where Antlr should generate files.
See Command Line Options -
grammars
Comma separated grammar file names or grammar pattern file names present in thesourceDirectory
directory.
See Command Line Options -
grammarDefs
Grammar list presents in thesourceDirectory
directory.
See Command Line Options
Example:<grammarDefs>
<grammar>
<name>myGrammar.g</name>
<glib>mySuperGrammar.g;myOtherSuperGrammar.g</glib>
</grammar>
</grammarDefs> -
debug
@Parameter(property="debug", defaultValue="false") private boolean debugLaunch the ParseView debugger upon parser invocation.
See Command Line Options -
diagnostic
@Parameter(property="diagnostic", defaultValue="false") private boolean diagnosticGenerate a text file from your grammar with a lot of debugging info.
See Command Line Options -
trace
@Parameter(property="trace", defaultValue="false") private boolean traceHave all rules call traceIn/traceOut.
See Command Line Options -
traceParser
@Parameter(property="traceParser", defaultValue="false") private boolean traceParserHave parser rules call traceIn/traceOut.
See Command Line Options -
traceLexer
@Parameter(property="traceLexer", defaultValue="false") private boolean traceLexerHave lexer rules call traceIn/traceOut.
See Command Line Options -
traceTreeParser
@Parameter(property="traceTreeParser", defaultValue="false") private boolean traceTreeParserHave tree rules call traceIn/traceOut.
See Command Line Options
-
-
Constructor Details
-
AbstractAntlrMojo
public AbstractAntlrMojo()
-
-
Method Details
-
getSourceDirectory
- Specified by:
getSourceDirectory
in interfaceEnvironment
-
getOutputDirectory
- Specified by:
getOutputDirectory
in interfaceEnvironment
-
executeAntlr
protected void executeAntlr() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
locateAntlrArtifact
protected final org.apache.maven.artifact.Artifact locateAntlrArtifact() throws AbstractAntlrMojo.NoAntlrDependencyDefinedException -
performGeneration
protected void performGeneration(GenerationPlan plan, org.apache.maven.artifact.Artifact antlrArtifact) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
generateClasspathForProcessSpawning
private String generateClasspathForProcessSpawning(org.apache.maven.artifact.Artifact antlrArtifact) -
executeAntlrInIsolatedClassLoader
private void executeAntlrInIsolatedClassLoader(String[] args, org.apache.maven.artifact.Artifact antlrArtifact) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
addArgs
Add arguments to be included in Antlr call- Parameters:
arguments
-
-
addArgIf
Convenience method to add an argument- Parameters:
arguments
-b
-value
-
-
getGeneratedFile
- Parameters:
grammar
-outputDir
-- Returns:
- generated file
- Throws:
IOException
-
validateParameters
private void validateParameters() throws org.apache.maven.plugin.MojoExecutionExceptiongrammars or grammarDefs parameters is required- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getGrammars
Get the list of all grammars to be compiled. The grammars variable can be a list of file or patterns. For instance, one can use *.g instead of a full list of grammar names. Be aware that sometime the grammar order is important, and that patterns won't keep this order, but we can still combine both elements( ordered names first, then the patterns). File name won't be added twice in the list of files.- Returns:
- an array of grammar from
grammars
andgrammarDefs
variables
-