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 Classes Modifier and Type Class Description static class
AbstractAntlrMojo.NoAntlrDependencyDefinedException
-
Field Summary
Fields Modifier and Type Field Description private boolean
debug
Launch the ParseView debugger upon parser invocation.private boolean
diagnostic
Generate a text file from your grammar with a lot of debugging info.protected Grammar[]
grammarDefs
Grammar list presents in thesourceDirectory
directory.protected java.lang.String
grammars
Comma separated grammar file names or grammar pattern file names present in thesourceDirectory
directory.protected java.io.File
outputDirectory
Specifies the destination directory where Antlr should generate files.protected org.apache.maven.project.MavenProject
project
The Maven Project Objectprivate org.apache.maven.project.MavenProjectHelper
projectHelper
The maven project's helper.protected java.io.File
sourceDirectory
Specifies the Antlr directory containing grammar files.private boolean
trace
Have all rules call traceIn/traceOut.private boolean
traceLexer
Have lexer rules call traceIn/traceOut.private boolean
traceParser
Have parser rules call traceIn/traceOut.private boolean
traceTreeParser
Have tree rules call traceIn/traceOut.
-
Constructor Summary
Constructors Constructor Description AbstractAntlrMojo()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static void
addArgIf(java.util.List arguments, boolean b, java.lang.String value)
Convenience method to add an argumentprotected abstract void
addArgs(java.util.List arguments)
Add arguments to be included in Antlr callprotected void
executeAntlr()
private void
executeAntlrInIsolatedClassLoader(java.lang.String[] args, org.apache.maven.artifact.Artifact antlrArtifact)
private java.lang.String
generateClasspathForProcessSpawning(org.apache.maven.artifact.Artifact antlrArtifact)
private java.io.File
getGeneratedFile(java.lang.String grammar, java.io.File outputDir)
private Grammar[]
getGrammars()
Get the list of all grammars to be compiled.java.io.File
getOutputDirectory()
java.io.File
getSourceDirectory()
protected org.apache.maven.artifact.Artifact
locateAntlrArtifact()
protected void
performGeneration(GenerationPlan plan, org.apache.maven.artifact.Artifact antlrArtifact)
private void
validateParameters()
grammars or grammarDefs parameters is required-
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
-
Methods inherited from interface org.codehaus.mojo.antlr.Environment
getLog
-
-
-
-
Field Detail
-
sourceDirectory
protected java.io.File sourceDirectory
Specifies the Antlr directory containing grammar files.
-
project
protected org.apache.maven.project.MavenProject project
The Maven Project Object
-
projectHelper
private org.apache.maven.project.MavenProjectHelper projectHelper
The maven project's helper.
-
outputDirectory
protected java.io.File outputDirectory
Specifies the destination directory where Antlr should generate files.
See Command Line Options
-
grammars
protected java.lang.String grammars
Comma separated grammar file names or grammar pattern file names present in thesourceDirectory
directory.
See Command Line Options
-
grammarDefs
protected Grammar[] 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
private boolean debug
Launch the ParseView debugger upon parser invocation.
See Command Line Options
-
diagnostic
private boolean diagnostic
Generate a text file from your grammar with a lot of debugging info.
See Command Line Options
-
trace
private boolean trace
Have all rules call traceIn/traceOut.
See Command Line Options
-
traceParser
private boolean traceParser
Have parser rules call traceIn/traceOut.
See Command Line Options
-
traceLexer
private boolean traceLexer
Have lexer rules call traceIn/traceOut.
See Command Line Options
-
traceTreeParser
private boolean traceTreeParser
Have tree rules call traceIn/traceOut.
See Command Line Options
-
-
Method Detail
-
getSourceDirectory
public java.io.File getSourceDirectory()
- Specified by:
getSourceDirectory
in interfaceEnvironment
-
getOutputDirectory
public java.io.File 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 java.lang.String generateClasspathForProcessSpawning(org.apache.maven.artifact.Artifact antlrArtifact)
-
executeAntlrInIsolatedClassLoader
private void executeAntlrInIsolatedClassLoader(java.lang.String[] args, org.apache.maven.artifact.Artifact antlrArtifact) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
addArgs
protected abstract void addArgs(java.util.List arguments)
Add arguments to be included in Antlr call- Parameters:
arguments
-
-
addArgIf
protected static void addArgIf(java.util.List arguments, boolean b, java.lang.String value)
Convenience method to add an argument- Parameters:
arguments
-b
-value
-
-
getGeneratedFile
private java.io.File getGeneratedFile(java.lang.String grammar, java.io.File outputDir) throws java.io.IOException
- Parameters:
grammar
-outputDir
-- Returns:
- generated file
- Throws:
java.io.IOException
-
validateParameters
private void validateParameters() throws org.apache.maven.plugin.MojoExecutionException
grammars or grammarDefs parameters is required- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getGrammars
private Grammar[] 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
-
-