From 5978c1489c530d89a0a3fb67cee541cfb2e4d2a6 Mon Sep 17 00:00:00 2001 From: Keegan Witt Date: Sat, 28 Mar 2020 23:16:00 -0400 Subject: [PATCH 1/5] Java 14 support --- .../gmavenplus/mojo/AbstractCompileMojo.java | 13 ++++++++++++- .../gmavenplus/mojo/AbstractGenerateStubsMojo.java | 13 ++++++++++++- .../gmavenplus/mojo/AbstractCompileMojoTest.java | 14 ++++++++++++++ .../mojo/AbstractGenerateStubsMojoTest.java | 14 ++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java index 5ef9d306b..c7d3078c2 100644 --- a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java +++ b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java @@ -40,6 +40,11 @@ */ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo { + /** + * Groovy 3.0.0 beta-2 version. + */ + protected static final Version GROOVY_3_0_0_BETA2 = new Version(3, 0, 0, "beta-2"); + /** * Groovy 3.0.0 beta-1 version. */ @@ -129,6 +134,7 @@ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo { *
  • 11
  • *
  • 12
  • *
  • 13
  • + *
  • 14
  • * * Using 1.6 or 1.7 requires Groovy >= 2.1.3. * Using 1.8 requires Groovy >= 2.3.3. @@ -136,6 +142,7 @@ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo { * Using 9 with invokedynamic requires Groovy >= 2.5.3, or Groovy >= 3.0.0 alpha 2, but not any 2.6 versions. * Using 10, 11, or 12 requires Groovy >= 2.5.3, or Groovy >= 3.0.0 alpha 4, but not any 2.6 versions. * Using 13 requires Groovy >= 2.5.7, or Groovy >= 3.0.0-beta-1, but not any 2.6 versions. + * Using 14 requires Groovy >= 3.0.0 beta-2. */ @Parameter(property = "maven.compiler.target", defaultValue = "1.8") protected String targetBytecode; @@ -396,7 +403,11 @@ protected Object setupCompilerConfiguration(final File compileOutputDirectory, f * org.codehaus.groovy.classgen.asm.WriterController. */ protected void verifyGroovyVersionSupportsTargetBytecode() { - if ("13".equals(targetBytecode)) { + if ("14".equals(targetBytecode)) { + if (groovyOlderThan(GROOVY_3_0_0_BETA2)) { + throw new IllegalArgumentException("Target bytecode 14 requires Groovy " + GROOVY_3_0_0_BETA2 + " or newer."); + } + } else if ("13".equals(targetBytecode)) { if (groovyOlderThan(GROOVY_2_5_7) || (groovyAtLeast(GROOVY_2_6_0_ALPHA1) && groovyOlderThan(GROOVY_3_0_0_BETA1))) { throw new IllegalArgumentException("Target bytecode 13 requires Groovy " + GROOVY_2_5_7 + "/" + GROOVY_3_0_0_BETA1 + " or newer. No 2.6 version is supported."); } diff --git a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java index 52b2fb1a3..fc02a418c 100644 --- a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java +++ b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java @@ -44,6 +44,11 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource * (although it does create the target directory) when I use other versions. */ + /** + * Groovy 3.0.0 beta-2 version. + */ + protected static final Version GROOVY_3_0_0_BETA2 = new Version(3, 0, 0, "beta-2"); + /** * Groovy 3.0.0 beta-1 version. */ @@ -133,6 +138,7 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource *
  • 11
  • *
  • 12
  • *
  • 13
  • + *
  • 14
  • * * Using 1.6 or 1.7 requires Groovy >= 2.1.3. * Using 1.8 requires Groovy >= 2.3.3. @@ -140,6 +146,7 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource * Using 9 with invokedynamic requires Groovy >= 2.5.3, or Groovy >= 3.0.0 alpha 2, but not any 2.6 versions. * Using 10, 11, or 12 requires Groovy >= 2.5.3, or Groovy >= 3.0.0 alpha 4, but not any 2.6 versions. * Using 13 requires Groovy >= 2.5.7, or Groovy >= 3.0.0-beta-1, but not any 2.6 versions. + * Using 14 requires Groovy >= 3.0.0 beta-2. * * @since 1.0-beta-3 */ @@ -364,7 +371,11 @@ protected void resetStubModifiedDates(final Set stubs) { * org.codehaus.groovy.classgen.asm.WriterController. */ protected void verifyGroovyVersionSupportsTargetBytecode() { - if ("13".equals(targetBytecode)) { + if ("14".equals(targetBytecode)) { + if (groovyOlderThan(GROOVY_3_0_0_BETA2)) { + throw new IllegalArgumentException("Target bytecode 14 requires Groovy " + GROOVY_3_0_0_BETA2 + " or newer."); + } + } else if ("13".equals(targetBytecode)) { if (groovyOlderThan(GROOVY_2_5_7) || (groovyAtLeast(GROOVY_2_6_0_ALPHA1) && groovyOlderThan(GROOVY_3_0_0_BETA1))) { throw new IllegalArgumentException("Target bytecode 13 requires Groovy " + GROOVY_2_5_7 + "/" + GROOVY_3_0_0_BETA1 + " or newer. No 2.6 version is supported."); } diff --git a/src/test/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojoTest.java b/src/test/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojoTest.java index 4b38868f3..336cb01ea 100644 --- a/src/test/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojoTest.java +++ b/src/test/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojoTest.java @@ -278,6 +278,20 @@ public void testJava13WithSupportedGroovy3() { testMojo.verifyGroovyVersionSupportsTargetBytecode(); } + @Test(expected = IllegalArgumentException.class) + public void testJava14WithUnsupportedGroovy() { + testMojo = new TestMojo("3.0.0-beta-1"); + testMojo.targetBytecode = "14"; + testMojo.verifyGroovyVersionSupportsTargetBytecode(); + } + + @Test + public void testJava14WithSupportedGroovy() { + testMojo = new TestMojo("3.0.0-beta-2"); + testMojo.targetBytecode = "14"; + testMojo.verifyGroovyVersionSupportsTargetBytecode(); + } + @Test(expected = IllegalArgumentException.class) public void testUnrecognizedJava() { testMojo = new TestMojo("2.1.2"); diff --git a/src/test/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojoTest.java b/src/test/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojoTest.java index fa35ffebf..742d0092a 100644 --- a/src/test/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojoTest.java +++ b/src/test/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojoTest.java @@ -314,6 +314,20 @@ public void testJava13WithSupportedGroovy3() { testMojo.verifyGroovyVersionSupportsTargetBytecode(); } + @Test(expected = IllegalArgumentException.class) + public void testJava14WithUnsupportedGroovy() { + testMojo = new TestMojo("3.0.0-beta-1"); + testMojo.targetBytecode = "14"; + testMojo.verifyGroovyVersionSupportsTargetBytecode(); + } + + @Test + public void testJava14WithSupportedGroovy() { + testMojo = new TestMojo("3.0.0-beta-2"); + testMojo.targetBytecode = "14"; + testMojo.verifyGroovyVersionSupportsTargetBytecode(); + } + protected static class TestMojo extends AbstractGenerateStubsMojo { protected TestMojo() { this(GROOVY_1_8_2.toString(), false); From 148300c9eaa76e579b02dd12ba52cb84ff50dc1a Mon Sep 17 00:00:00 2001 From: Keegan Witt Date: Sun, 29 Mar 2020 17:56:52 -0400 Subject: [PATCH 2/5] Java 15 support --- .../gmavenplus/mojo/AbstractCompileMojo.java | 13 ++++++++++++- .../gmavenplus/mojo/AbstractGenerateStubsMojo.java | 13 ++++++++++++- .../gmavenplus/mojo/AbstractCompileMojoTest.java | 14 ++++++++++++++ .../mojo/AbstractGenerateStubsMojoTest.java | 14 ++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java index c7d3078c2..396492152 100644 --- a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java +++ b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java @@ -40,6 +40,11 @@ */ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo { + /** + * Groovy 3.0.3 version. + */ + protected static final Version GROOVY_3_0_3 = new Version(3, 0, 3); + /** * Groovy 3.0.0 beta-2 version. */ @@ -135,6 +140,7 @@ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo { *
  • 12
  • *
  • 13
  • *
  • 14
  • + *
  • 15
  • * * Using 1.6 or 1.7 requires Groovy >= 2.1.3. * Using 1.8 requires Groovy >= 2.3.3. @@ -143,6 +149,7 @@ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo { * Using 10, 11, or 12 requires Groovy >= 2.5.3, or Groovy >= 3.0.0 alpha 4, but not any 2.6 versions. * Using 13 requires Groovy >= 2.5.7, or Groovy >= 3.0.0-beta-1, but not any 2.6 versions. * Using 14 requires Groovy >= 3.0.0 beta-2. + * Using 15 requires Groovy >= 3.0.3. */ @Parameter(property = "maven.compiler.target", defaultValue = "1.8") protected String targetBytecode; @@ -403,7 +410,11 @@ protected Object setupCompilerConfiguration(final File compileOutputDirectory, f * org.codehaus.groovy.classgen.asm.WriterController. */ protected void verifyGroovyVersionSupportsTargetBytecode() { - if ("14".equals(targetBytecode)) { + if ("15".equals(targetBytecode)) { + if (groovyOlderThan(GROOVY_3_0_3)) { + throw new IllegalArgumentException("Target bytecode 15 requires Groovy " + GROOVY_3_0_3 + " or newer."); + } + } else if ("14".equals(targetBytecode)) { if (groovyOlderThan(GROOVY_3_0_0_BETA2)) { throw new IllegalArgumentException("Target bytecode 14 requires Groovy " + GROOVY_3_0_0_BETA2 + " or newer."); } diff --git a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java index fc02a418c..4e441c7a2 100644 --- a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java +++ b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java @@ -44,6 +44,11 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource * (although it does create the target directory) when I use other versions. */ + /** + * Groovy 3.0.3 version. + */ + protected static final Version GROOVY_3_0_3 = new Version(3, 0, 3); + /** * Groovy 3.0.0 beta-2 version. */ @@ -139,6 +144,7 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource *
  • 12
  • *
  • 13
  • *
  • 14
  • + *
  • 15
  • * * Using 1.6 or 1.7 requires Groovy >= 2.1.3. * Using 1.8 requires Groovy >= 2.3.3. @@ -147,6 +153,7 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource * Using 10, 11, or 12 requires Groovy >= 2.5.3, or Groovy >= 3.0.0 alpha 4, but not any 2.6 versions. * Using 13 requires Groovy >= 2.5.7, or Groovy >= 3.0.0-beta-1, but not any 2.6 versions. * Using 14 requires Groovy >= 3.0.0 beta-2. + * Using 15 requires Groovy >= 3.0.3. * * @since 1.0-beta-3 */ @@ -371,7 +378,11 @@ protected void resetStubModifiedDates(final Set stubs) { * org.codehaus.groovy.classgen.asm.WriterController. */ protected void verifyGroovyVersionSupportsTargetBytecode() { - if ("14".equals(targetBytecode)) { + if ("15".equals(targetBytecode)) { + if (groovyOlderThan(GROOVY_3_0_3)) { + throw new IllegalArgumentException("Target bytecode 15 requires Groovy " + GROOVY_3_0_3 + " or newer."); + } + } else if ("14".equals(targetBytecode)) { if (groovyOlderThan(GROOVY_3_0_0_BETA2)) { throw new IllegalArgumentException("Target bytecode 14 requires Groovy " + GROOVY_3_0_0_BETA2 + " or newer."); } diff --git a/src/test/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojoTest.java b/src/test/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojoTest.java index 336cb01ea..da39d9930 100644 --- a/src/test/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojoTest.java +++ b/src/test/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojoTest.java @@ -292,6 +292,20 @@ public void testJava14WithSupportedGroovy() { testMojo.verifyGroovyVersionSupportsTargetBytecode(); } + @Test(expected = IllegalArgumentException.class) + public void testJava15WithUnsupportedGroovy() { + testMojo = new TestMojo("3.0.2"); + testMojo.targetBytecode = "15"; + testMojo.verifyGroovyVersionSupportsTargetBytecode(); + } + + @Test + public void testJava15WithSupportedGroovy() { + testMojo = new TestMojo("3.0.3"); + testMojo.targetBytecode = "15"; + testMojo.verifyGroovyVersionSupportsTargetBytecode(); + } + @Test(expected = IllegalArgumentException.class) public void testUnrecognizedJava() { testMojo = new TestMojo("2.1.2"); diff --git a/src/test/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojoTest.java b/src/test/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojoTest.java index 742d0092a..753d74515 100644 --- a/src/test/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojoTest.java +++ b/src/test/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojoTest.java @@ -328,6 +328,20 @@ public void testJava14WithSupportedGroovy() { testMojo.verifyGroovyVersionSupportsTargetBytecode(); } + @Test(expected = IllegalArgumentException.class) + public void testJava15WithUnsupportedGroovy() { + testMojo = new TestMojo("3.0.2"); + testMojo.targetBytecode = "15"; + testMojo.verifyGroovyVersionSupportsTargetBytecode(); + } + + @Test + public void testJava15WithSupportedGroovy() { + testMojo = new TestMojo("3.0.3"); + testMojo.targetBytecode = "15"; + testMojo.verifyGroovyVersionSupportsTargetBytecode(); + } + protected static class TestMojo extends AbstractGenerateStubsMojo { protected TestMojo() { this(GROOVY_1_8_2.toString(), false); From 625f5e669f4208c8de83b68b21aa22839f0c289d Mon Sep 17 00:00:00 2001 From: Keegan Witt Date: Sun, 29 Mar 2020 18:00:34 -0400 Subject: [PATCH 3/5] Add parameter to skip bytecode compatibility check --- .../codehaus/gmavenplus/mojo/AbstractCompileMojo.java | 10 +++++++++- .../gmavenplus/mojo/AbstractGenerateStubsMojo.java | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java index 396492152..f67a45338 100644 --- a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java +++ b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java @@ -154,6 +154,14 @@ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo { @Parameter(property = "maven.compiler.target", defaultValue = "1.8") protected String targetBytecode; + /** + * Whether to check that the version of Groovy used is able to use the requested targetBytecode. + * + * @since 1.9.0 + */ + @Parameter(property = "skipBytecodeCheck", defaultValue = "false") + protected boolean skipBytecodeCheck; + /** * Whether Groovy compiler should be set to debug. */ @@ -256,7 +264,7 @@ protected synchronized void doCompile(final Set sources, final List classp logPluginClasspath(); classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal()); - if (groovyVersionSupportsAction()) { + if (groovyVersionSupportsAction() && !skipBytecodeCheck) { verifyGroovyVersionSupportsTargetBytecode(); } else { getLog().error("Your Groovy version (" + classWrangler.getGroovyVersionString() + ") doesn't support compilation. The minimum version of Groovy required is " + minGroovyVersion + ". Skipping compiling."); diff --git a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java index 4e441c7a2..a6e03ae20 100644 --- a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java +++ b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java @@ -160,6 +160,14 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource @Parameter(property = "maven.compiler.target", defaultValue = "1.8") protected String targetBytecode; + /** + * Whether to check that the version of Groovy used is able to use the requested targetBytecode. + * + * @since 1.9.0 + */ + @Parameter(property = "skipBytecodeCheck", defaultValue = "false") + protected boolean skipBytecodeCheck; + /** * Whether Groovy compiler should be set to debug. */ @@ -240,7 +248,7 @@ protected synchronized void doStubGeneration(final Set stubSources, final logPluginClasspath(); classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal()); - if (groovyVersionSupportsAction()) { + if (groovyVersionSupportsAction() && !skipBytecodeCheck) { verifyGroovyVersionSupportsTargetBytecode(); } else { getLog().error("Your Groovy version (" + classWrangler.getGroovyVersionString() + ") doesn't support stub generation. The minimum version of Groovy required is " + minGroovyVersion + ". Skipping stub generation."); From ec3c2be22ada98522b7f288b2f54e69a695159bb Mon Sep 17 00:00:00 2001 From: Keegan Witt Date: Sun, 29 Mar 2020 04:40:44 -0400 Subject: [PATCH 4/5] Rename groovydoc skip property to clarify it's not a standard Maven plugin property --- .../org/codehaus/gmavenplus/mojo/AbstractGroovyDocMojo.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGroovyDocMojo.java b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGroovyDocMojo.java index 586fdc864..d069535f8 100644 --- a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGroovyDocMojo.java +++ b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGroovyDocMojo.java @@ -137,7 +137,7 @@ public abstract class AbstractGroovyDocMojo extends AbstractGroovySourcesMojo { * * @since 1.6 */ - @Parameter(property = "maven.groovydoc.skip", defaultValue = "false") + @Parameter(property = "skipGroovydoc", defaultValue = "false") protected boolean skipGroovyDoc; /** @@ -168,7 +168,7 @@ public abstract class AbstractGroovyDocMojo extends AbstractGroovySourcesMojo { */ protected synchronized void doGroovyDocGeneration(final FileSet[] sourceDirectories, final List classpath, final File outputDirectory) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException, InstantiationException, MalformedURLException { if (skipGroovyDoc) { - getLog().info("Skipping generation of GroovyDoc because ${maven.groovydoc.skip} was set to true."); + getLog().info("Skipping generation of GroovyDoc because ${skipGroovydoc} was set to true."); return; } From fe3320f126499148cd10adb9044d2c7a66f2e13c Mon Sep 17 00:00:00 2001 From: Keegan Witt Date: Sun, 29 Mar 2020 18:57:47 -0400 Subject: [PATCH 5/5] Bump version to 1.9.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c2b853804..04534aea7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.codehaus.gmavenplus gmavenplus-plugin maven-plugin - 1.8.2-SNAPSHOT + 1.9.0-SNAPSHOT UTF-8