From 63690976307ce27b659fe785da0e557812dd1abf Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 26 Nov 2012 20:14:58 -0600 Subject: [PATCH 1/7] Remove unnecessary dependency on ST4 --- runtime/Java/pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/runtime/Java/pom.xml b/runtime/Java/pom.xml index fae2d6b1d..eb252a13f 100644 --- a/runtime/Java/pom.xml +++ b/runtime/Java/pom.xml @@ -15,12 +15,6 @@ ANTLR 4 Runtime - - org.antlr - ST4 - 4.0.4 - compile - org.abego.treelayout org.abego.treelayout.core From 769e0a418eff3cdfe085565b4e6f80d7695c065a Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 26 Nov 2012 20:19:09 -0600 Subject: [PATCH 2/7] Updated javadoc --- .../Java/src/org/antlr/v4/runtime/misc/IntegerList.java | 9 +++++---- .../src/org/antlr/v4/runtime/tree/ParseTreeVisitor.java | 4 ++-- tool/src/org/antlr/v4/Tool.java | 1 - 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/IntegerList.java b/runtime/Java/src/org/antlr/v4/runtime/misc/IntegerList.java index 21ae22656..afade609b 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/misc/IntegerList.java +++ b/runtime/Java/src/org/antlr/v4/runtime/misc/IntegerList.java @@ -31,6 +31,7 @@ package org.antlr.v4.runtime.misc; import java.util.Arrays; import java.util.Collection; +import java.util.List; /** * @@ -191,14 +192,14 @@ public class IntegerList { /** * Compares the specified object with this list for equality. Returns - * {@code true} if and only if the specified object is also an {@code IntegerList}, + * {@code true} if and only if the specified object is also an {@link IntegerList}, * both lists have the same size, and all corresponding pairs of elements in * the two lists are equal. In other words, two lists are defined to be * equal if they contain the same elements in the same order. *

* This implementation first checks if the specified object is this * list. If so, it returns {@code true}; if not, it checks if the - * specified object is an {@code IntegerList}. If not, it returns {@code false}; + * specified object is an {@link IntegerList}. If not, it returns {@code false}; * if so, it checks the size of both lists. If the lists are not the same size, * it returns {@code false}; otherwise it iterates over both lists, comparing * corresponding pairs of elements. If any comparison returns {@code false}, @@ -233,8 +234,8 @@ public class IntegerList { /** * Returns the hash code value for this list. - * - *

This implementation uses exactly the code that is used to define the + *

+ * This implementation uses exactly the code that is used to define the * list hash function in the documentation for the {@link List#hashCode} * method. * diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeVisitor.java b/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeVisitor.java index 7baa1650e..ce6e90edd 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeVisitor.java +++ b/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTreeVisitor.java @@ -110,7 +110,7 @@ public class ParseTreeVisitor { * * @param aggregate The previous aggregate value. In the default * implementation, the aggregate value is initialized to - * {@link #defaultValue}, which is passed as the {@code aggregate} argument + * {@link #defaultResult}, which is passed as the {@code aggregate} argument * to this method after the first child node is visited. * @param nextResult The result of the immediately preceeding call to visit * a child node. @@ -126,7 +126,7 @@ public class ParseTreeVisitor { * {@link #visitChildren}. This method is first called before the first * child is visited; at that point {@code currentResult} will be the initial * value (in the default implementation, the initial value is returned by a - * call to {@link #defaultValue}. + * call to {@link #defaultResult}. *

* The default implementation always returns {@code true}, indicating that * {@code visitChildren} should only return after all children are visited. diff --git a/tool/src/org/antlr/v4/Tool.java b/tool/src/org/antlr/v4/Tool.java index 083a66bbf..26b8307ed 100644 --- a/tool/src/org/antlr/v4/Tool.java +++ b/tool/src/org/antlr/v4/Tool.java @@ -724,7 +724,6 @@ public class Tool { * given relative to the input directory. * * @param fileNameWithPath path to input source - * @return */ public File getOutputDirectory(String fileNameWithPath) { File outputDir; From 5b4809deb6085ba849d2bba3c2337277a93229ad Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 26 Nov 2012 20:21:38 -0600 Subject: [PATCH 3/7] Include source and javadoc jars in maven builds --- runtime/Java/pom.xml | 28 ++++++++++++++++++++++++++++ tool/pom.xml | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/runtime/Java/pom.xml b/runtime/Java/pom.xml index eb252a13f..1059e0af5 100644 --- a/runtime/Java/pom.xml +++ b/runtime/Java/pom.xml @@ -43,6 +43,34 @@ -Xlint:-serial + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9 + + + attach-javadocs + + jar + + + + diff --git a/tool/pom.xml b/tool/pom.xml index ce5937bf5..fa7682fe8 100644 --- a/tool/pom.xml +++ b/tool/pom.xml @@ -80,6 +80,34 @@ + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9 + + + attach-javadocs + + jar + + + + + maven-surefire-plugin 2.12 From d68f75067d6cd16f05373a9fc6f7c69f25dd412b Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 26 Nov 2012 20:24:35 -0600 Subject: [PATCH 4/7] Updated library and plugin references --- antlr4-maven-plugin/pom.xml | 16 ++++++++-------- runtime/Java/pom.xml | 2 +- tool/pom.xml | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/antlr4-maven-plugin/pom.xml b/antlr4-maven-plugin/pom.xml index 85a83c269..7267311a3 100644 --- a/antlr4-maven-plugin/pom.xml +++ b/antlr4-maven-plugin/pom.xml @@ -194,20 +194,20 @@ org.apache.maven maven-plugin-api - 2.0 + 3.0.4 compile org.apache.maven maven-project - 2.0 + 2.2.1 org.codehaus.plexus plexus-compiler-api - 1.8.6 + 2.0 + true + + + + mojo-descriptor + + descriptor + + + + help-goal + + helpmojo + + + + + org.apache.maven.plugins maven-site-plugin diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java index a820a85b5..a333b81f8 100644 --- a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java +++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java @@ -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 Jim Idle */ +@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 Dot format - * - * @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 includes = new HashSet(); /** * 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 excludes = new HashSet(); /** - * @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. .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/antlr4/imports" */ + @Parameter(defaultValue = "${basedir}/src/main/antlr4/imports") private File libDirectory; public File getSourceDirectory() { From 348adb5398406d49881c1f6ca25f6144dafe37b9 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 26 Nov 2012 22:33:08 -0600 Subject: [PATCH 6/7] Fix rawtypes warning --- .../src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java index a333b81f8..f0bbb8998 100644 --- a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java +++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4Mojo.java @@ -466,7 +466,7 @@ public class Antlr4Mojo throws TokenStreamException, RecognitionException, IOException, InclusionScanException { // Which files under the source set should we be looking for as grammar files // - SourceMapping mapping = new SuffixMapping("g4", Collections.EMPTY_SET); + SourceMapping mapping = new SuffixMapping("g4", Collections.emptySet()); // What are the sets of includes (defaulted or otherwise). // From 3117a4e9e1e1ad1adcd968d1a4b4f9399f9ce2d7 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 26 Nov 2012 22:33:21 -0600 Subject: [PATCH 7/7] Generate javadoc and fix warning --- antlr4-maven-plugin/pom.xml | 14 ++++++++++++++ .../java/org/antlr/mojo/antlr4/Antlr4ErrorLog.java | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/antlr4-maven-plugin/pom.xml b/antlr4-maven-plugin/pom.xml index d405b1156..84959b7cb 100644 --- a/antlr4-maven-plugin/pom.xml +++ b/antlr4-maven-plugin/pom.xml @@ -330,6 +330,20 @@ + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9 + + + attach-javadocs + + jar + + + + + diff --git a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4ErrorLog.java b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4ErrorLog.java index 1172ac798..49fb58f02 100644 --- a/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4ErrorLog.java +++ b/antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/Antlr4ErrorLog.java @@ -55,7 +55,7 @@ public class Antlr4ErrorLog implements ANTLRToolListener { /** * Sends an informational message to the Maven log sink. - * @param s The message to send to Maven + * @param message The message to send to Maven */ @Override public void info(String message) {