diff --git a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java index fe1a20bb..edd34d94 100644 --- a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java +++ b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java @@ -44,6 +44,11 @@ */ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo { + /** + * Groovy 4.0.6 version. + */ + protected static final Version GROOVY_4_0_6 = new Version(4, 0, 6); + /** * Groovy 4.0.2 version. */ @@ -196,6 +201,7 @@ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo { * Using 17 requires Groovy >= 3.0.8 or Groovy > 4.0.0-alpha-3. * Using 18 requires Groovy > 4.0.0-beta-1. * Using 19 requires Groovy > 4.0.2. + * Using 20 requires Groovy > 4.0.6. */ @Parameter(property = "maven.compiler.target", defaultValue = "1.8") protected String targetBytecode; @@ -484,7 +490,11 @@ protected Object setupCompilerConfiguration(final File compileOutputDirectory, f * org.codehaus.groovy.classgen.asm.WriterController. */ protected void verifyGroovyVersionSupportsTargetBytecode() { - if ("19".equals(targetBytecode)) { + if ("20".equals(targetBytecode)) { + if (groovyOlderThan(GROOVY_4_0_6)) { + throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_6 + " or newer."); + } + } else if ("19".equals(targetBytecode)) { if (groovyOlderThan(GROOVY_4_0_2)) { throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_2 + " 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 dfe91a95..4a66a058 100644 --- a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java +++ b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java @@ -46,6 +46,11 @@ */ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSourcesMojo { + /** + * Groovy 4.0.6 version. + */ + protected static final Version GROOVY_4_0_6 = new Version(4, 0, 6); + /** * Groovy 4.0.2 version. */ @@ -199,6 +204,7 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource * Using 17 requires Groovy >= 3.0.8 or Groovy > 4.0.0-alpha-3. * Using 18 requires Groovy > 4.0.0-beta-1. * Using 19 requires Groovy > 4.0.2. + * Using 20 requires Groovy > 4.0.6. * * @since 1.0-beta-3 */ @@ -411,7 +417,11 @@ protected void resetStubModifiedDates(final Set stubs) { * org.codehaus.groovy.classgen.asm.WriterController. */ protected void verifyGroovyVersionSupportsTargetBytecode() { - if ("19".equals(targetBytecode)) { + if ("20".equals(targetBytecode)) { + if (groovyOlderThan(GROOVY_4_0_6)) { + throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_6 + " or newer."); + } + } else if ("19".equals(targetBytecode)) { if (groovyOlderThan(GROOVY_4_0_2)) { throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_2 + " 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 22493431..8657b1ce 100644 --- a/src/test/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojoTest.java +++ b/src/test/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojoTest.java @@ -391,6 +391,20 @@ public void testJava19WithSupportedGroovy() { testMojo.verifyGroovyVersionSupportsTargetBytecode(); } + @Test(expected = IllegalArgumentException.class) + public void testJava20WithUnsupportedGroovy() { + testMojo = new TestMojo("4.0.5"); + testMojo.targetBytecode = "20"; + testMojo.verifyGroovyVersionSupportsTargetBytecode(); + } + + @Test + public void testJava20WithSupportedGroovy() { + testMojo = new TestMojo("4.0.6"); + testMojo.targetBytecode = "20"; + 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 88e40732..1ba2d433 100644 --- a/src/test/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojoTest.java +++ b/src/test/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojoTest.java @@ -418,6 +418,20 @@ public void testJava19WithSupportedGroovy() { testMojo.verifyGroovyVersionSupportsTargetBytecode(); } + @Test(expected = IllegalArgumentException.class) + public void testJava20WithUnsupportedGroovy() { + testMojo = new TestMojo("4.0.5"); + testMojo.targetBytecode = "20"; + testMojo.verifyGroovyVersionSupportsTargetBytecode(); + } + + @Test + public void testJava20WithSupportedGroovy() { + testMojo = new TestMojo("4.0.6"); + testMojo.targetBytecode = "20"; + testMojo.verifyGroovyVersionSupportsTargetBytecode(); + } + @Test(expected = IllegalArgumentException.class) public void testUnrecognizedJava() { testMojo = new TestMojo("2.1.2");