Use annotations for plugin registration
This commit is contained in:
parent
d68f75067d
commit
8295d9f90c
|
@ -239,7 +239,14 @@
|
|||
<version>1.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||
<artifactId>maven-plugin-annotations</artifactId>
|
||||
<version>3.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -270,6 +277,30 @@
|
|||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<version>3.2</version>
|
||||
<configuration>
|
||||
<!-- see http://jira.codehaus.org/browse/MNG-5346 -->
|
||||
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>mojo-descriptor</id>
|
||||
<goals>
|
||||
<goal>descriptor</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>help-goal</id>
|
||||
<goals>
|
||||
<goal>helpmojo</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
|
|
|
@ -43,6 +43,10 @@ import org.apache.maven.plugin.AbstractMojo;
|
|||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
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;
|
||||
import org.codehaus.plexus.compiler.util.scan.InclusionScanException;
|
||||
import org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner;
|
||||
|
@ -67,15 +71,14 @@ import java.util.Set;
|
|||
* Goal that picks up all the ANTLR grammars in a project and moves those that
|
||||
* are required for generation of the compilable sources into the location
|
||||
* that we use to compile them, such as target/generated-sources/antlr4 ...
|
||||
*
|
||||
* @goal antlr
|
||||
*
|
||||
* @phase process-sources
|
||||
* @requiresDependencyResolution compile
|
||||
* @requiresProject true
|
||||
*
|
||||
* @author <a href="mailto:jimi@temporal-wave.com">Jim Idle</a>
|
||||
*/
|
||||
@Mojo(
|
||||
name = "antlr",
|
||||
defaultPhase = LifecyclePhase.PROCESS_SOURCES,
|
||||
requiresDependencyResolution = ResolutionScope.COMPILE,
|
||||
requiresProject = true)
|
||||
public class Antlr4Mojo
|
||||
extends AbstractMojo {
|
||||
|
||||
|
@ -86,60 +89,52 @@ public class Antlr4Mojo
|
|||
* If set to true, then after the tool has processed an input grammar file
|
||||
* it will report variaous statistics about the parser, such as information
|
||||
* on cyclic DFAs, which rules may use backtracking, and so on.
|
||||
*
|
||||
* @parameter default-value="false"
|
||||
*/
|
||||
@Parameter(defaultValue = "false")
|
||||
protected boolean report;
|
||||
/**
|
||||
* If set to true, then the ANTLR tool will print a version of the input
|
||||
* grammar which is devoid of any actions that may be present in the input file.
|
||||
*
|
||||
* @parameter default-value="false"
|
||||
*/
|
||||
@Parameter(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(defaultValue = "false")
|
||||
protected boolean debug;
|
||||
/**
|
||||
* If set to true, then then the generated parser will compute and report on
|
||||
* profile information at runtime.
|
||||
*
|
||||
* @parameter default-value="false"
|
||||
*/
|
||||
@Parameter(defaultValue = "false")
|
||||
protected boolean profile;
|
||||
/**
|
||||
* If set to true then the ANTLR tool will generate a description of the atn
|
||||
* for each rule in <a href="http://www.graphviz.org">Dot format</a>
|
||||
*
|
||||
* @parameter default-value="false"
|
||||
*/
|
||||
@Parameter(defaultValue = "false")
|
||||
protected boolean atn;
|
||||
/**
|
||||
* If set to true, the generated parser code will log rule entry and exit points
|
||||
* to stdout as an aid to debugging.
|
||||
*
|
||||
* @parameter default-value="false"
|
||||
*/
|
||||
@Parameter(defaultValue = "false")
|
||||
protected boolean trace;
|
||||
/**
|
||||
* If this parameter is set, it indicates that any warning or error messages returned
|
||||
* by ANLTR, shoould be formatted in the specified way. Currently, ANTLR suports the
|
||||
* built-in formats of antlr, gnu and vs2005.
|
||||
*
|
||||
* @parameter default-value="antlr"
|
||||
*/
|
||||
@Parameter(defaultValue = "antlr")
|
||||
protected String messageFormat;
|
||||
/**
|
||||
* If this parameter is set to true, then ANTLR will report all sorts of things
|
||||
* about what it is doing such as the names of files and the version of ANTLR and so on.
|
||||
*
|
||||
* @parameter default-value="true"
|
||||
*/
|
||||
@Parameter(defaultValue = "true")
|
||||
protected boolean verbose;
|
||||
|
||||
protected boolean verbose_dfa;
|
||||
|
@ -151,9 +146,8 @@ public class Antlr4Mojo
|
|||
/**
|
||||
* The number of alts, beyond which ANTLR will not generate a switch statement
|
||||
* for the DFA.
|
||||
*
|
||||
* @parameter default-value="300"
|
||||
*/
|
||||
@Parameter(defaultValue = "300")
|
||||
private int maxSwitchCaseLabels;
|
||||
|
||||
/**
|
||||
|
@ -177,50 +171,41 @@ public class Antlr4Mojo
|
|||
* this version of the plugin looks for the directory antlr4 and not the directory
|
||||
* antlr, so as to avoid clashes and confusion for projects that use both v3 and v4 grammars
|
||||
* such as ANTLR itself.
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
@Parameter
|
||||
protected Set<String> includes = new HashSet<String>();
|
||||
/**
|
||||
* Provides an explicit list of any grammars that should be excluded from
|
||||
* the generate phase of the plugin. Files listed here will not be sent for
|
||||
* processing by the ANTLR tool.
|
||||
*
|
||||
* @parameter
|
||||
*/
|
||||
@Parameter
|
||||
protected Set<String> excludes = new HashSet<String>();
|
||||
/**
|
||||
* @parameter expression="${project}"
|
||||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
@Parameter(property = "project", required = true, readonly = true)
|
||||
protected MavenProject project;
|
||||
/**
|
||||
* Specifies the Antlr directory containing grammar files. For
|
||||
* antlr version 4.x we default this to a directory in the tree
|
||||
* called antlr4 because the antlr3 directory is occupied by version
|
||||
* 3.x grammars.
|
||||
*
|
||||
* @parameter default-value="${basedir}/src/main/antlr4"
|
||||
* @required
|
||||
*/
|
||||
@Parameter(defaultValue = "${basedir}/src/main/antlr4", required = true)
|
||||
private File sourceDirectory;
|
||||
/**
|
||||
* Location for generated Java files. For antlr version 4.x we default
|
||||
* this to a directory in the tree called antlr4 because the antlr
|
||||
* directory is occupied by version 2.x grammars.
|
||||
*
|
||||
* @parameter default-value="${project.build.directory}/generated-sources/antlr4"
|
||||
* @required
|
||||
*/
|
||||
@Parameter(defaultValue = "${project.build.directory}/generated-sources/antlr4", required = true)
|
||||
private File outputDirectory;
|
||||
/**
|
||||
* Location for imported token files, e.g. <code>.tokens</code> 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/antlr4/imports"
|
||||
*/
|
||||
@Parameter(defaultValue = "${basedir}/src/main/antlr4/imports")
|
||||
private File libDirectory;
|
||||
|
||||
public File getSourceDirectory() {
|
||||
|
|
Loading…
Reference in New Issue