aboutsummaryrefslogtreecommitdiff
path: root/antlr3-maven-plugin/src/main/java/org/antlr/mojo/antlr3/Antlr3Mojo.java
diff options
context:
space:
mode:
Diffstat (limited to 'antlr3-maven-plugin/src/main/java/org/antlr/mojo/antlr3/Antlr3Mojo.java')
-rw-r--r--antlr3-maven-plugin/src/main/java/org/antlr/mojo/antlr3/Antlr3Mojo.java73
1 files changed, 29 insertions, 44 deletions
diff --git a/antlr3-maven-plugin/src/main/java/org/antlr/mojo/antlr3/Antlr3Mojo.java b/antlr3-maven-plugin/src/main/java/org/antlr/mojo/antlr3/Antlr3Mojo.java
index 6c18c55..13a3465 100644
--- a/antlr3-maven-plugin/src/main/java/org/antlr/mojo/antlr3/Antlr3Mojo.java
+++ b/antlr3-maven-plugin/src/main/java/org/antlr/mojo/antlr3/Antlr3Mojo.java
@@ -51,20 +51,25 @@ import org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner;
import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner;
import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping;
import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.MavenProject;
/**
* Parses ANTLR grammar files {@code *.g} and transforms them into Java source
* files.
*
- * @goal antlr
- * @phase generate-sources
- * @requiresDependencyResolution compile
- * @requiresProject true
- *
* @author <a href="mailto:jimi@temporal-wave.com">Jim Idle</a>
*/
-public class Antlr3Mojo
- extends AbstractMojo {
+@Mojo(
+ name = "antlr",
+ defaultPhase = LifecyclePhase.GENERATE_SOURCES,
+ requiresDependencyResolution = ResolutionScope.COMPILE,
+ requiresProject = true, threadSafe = true)
+public class Antlr3Mojo extends AbstractMojo {
// First, let's deal with the options that the ANTLR tool itself
// can be configured by.
@@ -73,88 +78,77 @@ public class Antlr3Mojo
* If set to true, then after the tool has processed an input grammar file
* it will report various statistics about the parser, such as information
* on cyclic DFAs, which rules may use backtracking, and so on.
- *
- * @parameter default-value="false"
*/
+ @Parameter(property = "report", defaultValue = "false")
protected boolean report;
/**
* If set to true, then the ANTLR tool will print a version of the input
* grammar(s) which are stripped of any embedded actions.
- *
- * @parameter default-value="false"
*/
+ @Parameter(property = "printGrammar", defaultValue = "false")
protected boolean printGrammar;
/**
* If set to true, then the code generated by the ANTLR code generator will
* be set to debug mode. This means that when run, the code will 'hang' and
* wait for a debug connection on a TCP port (49100 by default).
- *
- * @parameter default-value="false"
*/
+ @Parameter(property = "debug", defaultValue = "false")
protected boolean debug;
/**
* If set to true, then the generated parser will compute and report profile
* information at runtime.
- *
- * @parameter default-value="false"
*/
+ @Parameter(property = "profile", defaultValue = "false")
protected boolean profile;
/**
* If set to true, then the ANTLR tool will generate a description of the
* NFA for each rule in <a href="http://www.graphviz.org">Dot format</a>
- *
- * @parameter default-value="false"
*/
+ @Parameter(property = "nfa", defaultValue = "false")
protected boolean nfa;
/**
* If set to true, then the ANTLR tool will generate a description of the
* DFA for each decision in the grammar in
* <a href="http://www.graphviz.org">Dot format</a>.
- *
- * @parameter default-value="false"
*/
+ @Parameter(property = "dfa", defaultValue = "false")
protected boolean dfa;
/**
* If set to true, the generated parser code will log rule entry and exit
* points to stdout ({@link System#out} for the Java target) as an aid to
* debugging.
- *
- * @parameter default-value="false"
*/
+ @Parameter(property = "trace", defaultValue = "false")
protected boolean trace;
/**
* If this parameter is set, it indicates that any warning or error messages
* returned by ANLTR, should be formatted in the specified way. Currently,
* ANTLR supports the built-in formats {@code antlr}, {@code gnu} and
* {@code vs2005}.
- *
- * @parameter default-value="antlr"
*/
+ @Parameter(property = "messageFormat", defaultValue = "antlr")
protected String messageFormat;
/**
* If set to true, then ANTLR will report verbose messages during the code
* generation process. This includes the names of files, the version of
* ANTLR, and more.
- *
- * @parameter default-value="true"
*/
+ @Parameter(property = "verbose", defaultValue = "true")
protected boolean verbose;
/**
* The maximum number of alternatives allowed in an inline switch statement.
* Beyond this, ANTLR will not generate a switch statement for the DFA.
- *
- * @parameter default-value="300"
*/
+ @Parameter(property = "maxSwitchCaseLabels", defaultValue = "300")
private int maxSwitchCaseLabels;
/**
* The minimum number of alternatives for ANTLR to generate a switch
* statement. For decisions with fewer alternatives, an if/else if/else
* statement will be used instead.
- *
- * @parameter default-value="3"
*/
+ @Parameter(property = "minSwitchAlts", defaultValue = "3")
private int minSwitchAlts;
/* --------------------------------------------------------------------
@@ -171,49 +165,40 @@ public class Antlr3Mojo
* A set of Ant-like inclusion patterns used to select files from the source
* directory for processing. By default, the pattern <code>**&#47;*.g</code>
* is used to select grammar files.</p>
- *
- * @parameter
*/
+ @Parameter
protected Set<String> includes = new HashSet<String>();
/**
* 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.
- *
- * @parameter
*/
+ @Parameter
protected Set<String> excludes = new HashSet<String>();
/**
* The current Maven project.
- *
- * @parameter expression="${project}"
- * @required
- * @readonly
*/
+ @Parameter(property = "project", required = true, readonly = true)
protected MavenProject project;
/**
* The directory where the ANTLR grammar files ({@code *.g}) are located.
- *
- * @parameter default-value="${basedir}/src/main/antlr3"
*/
+ @Parameter(defaultValue = "${basedir}/src/main/antlr3")
private File sourceDirectory;
/**
* The directory where the parser files generated by ANTLR will be stored.
* The directory will be registered as a compile source root of the project
* such that the generated files will participate in later build phases like
* compiling and packaging.
- *
- * @parameter default-value="${project.build.directory}/generated-sources/antlr3"
- * @required
*/
+ @Parameter(defaultValue = "${project.build.directory}/generated-sources/antlr3", required = true)
private File outputDirectory;
/**
* Location for imported token files, e.g. {@code *.tokens} and imported
* grammars. Note that ANTLR will not try to process grammars that it finds
* to be imported into other grammars (in the same processing session).
- *
- * @parameter default-value="${basedir}/src/main/antlr3/imports"
*/
+ @Parameter(defaultValue = "${basedir}/src/main/antlr3/imports")
private File libDirectory;
public File getSourceDirectory() {