Skip to content

Commit

Permalink
Merge pull request #264 from bmarwell/support_jdk21
Browse files Browse the repository at this point in the history
Support JDK21
  • Loading branch information
keeganwitt committed Sep 25, 2023
2 parents c70b3cb + 33606ea commit 5093cfc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
*/
public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo {

/**
* Groovy 4.0.11 version.
*/
protected static final Version GROOVY_4_0_11 = new Version(4, 0, 11);

/**
* Groovy 4.0.6 version.
*/
Expand Down Expand Up @@ -202,6 +207,7 @@ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo {
* Using 18 requires Groovy > 4.0.0-beta-1.
* Using 19 requires Groovy > 4.0.2.
* Using 20 requires Groovy > 4.0.6.
* Using 21 requires Groovy > 4.0.11.
*/
@Parameter(property = "maven.compiler.target", defaultValue = "1.8")
protected String targetBytecode;
Expand Down Expand Up @@ -490,7 +496,11 @@ protected Object setupCompilerConfiguration(final File compileOutputDirectory, f
* org.codehaus.groovy.classgen.asm.WriterController.
*/
protected void verifyGroovyVersionSupportsTargetBytecode() {
if ("20".equals(targetBytecode)) {
if ("21".equals(targetBytecode)) {
if (groovyOlderThan(GROOVY_4_0_11)) {
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_11 + " or newer.");
}
} else if ("20".equals(targetBytecode)) {
if (groovyOlderThan(GROOVY_4_0_6)) {
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_6 + " or newer.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
*/
public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSourcesMojo {

/**
* Groovy 4.0.11 version.
*/
protected static final Version GROOVY_4_0_11 = new Version(4, 0, 11);

/**
* Groovy 4.0.6 version.
*/
Expand Down Expand Up @@ -205,6 +210,7 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource
* Using 18 requires Groovy > 4.0.0-beta-1.
* Using 19 requires Groovy > 4.0.2.
* Using 20 requires Groovy > 4.0.6.
* Using 21 requires Groovy > 4.0.11.
*
* @since 1.0-beta-3
*/
Expand Down Expand Up @@ -417,7 +423,11 @@ protected void resetStubModifiedDates(final Set<File> stubs) {
* org.codehaus.groovy.classgen.asm.WriterController.
*/
protected void verifyGroovyVersionSupportsTargetBytecode() {
if ("20".equals(targetBytecode)) {
if ("21".equals(targetBytecode)) {
if (groovyOlderThan(GROOVY_4_0_11)) {
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_11 + " or newer.");
}
} else if ("20".equals(targetBytecode)) {
if (groovyOlderThan(GROOVY_4_0_6)) {
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_6 + " or newer.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,13 @@ public void testJava20WithSupportedGroovy() {
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

@Test
public void testJava21WithSupportedGroovy() {
testMojo = new TestMojo("4.0.11");
testMojo.targetBytecode = "21";
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

@Test(expected = IllegalArgumentException.class)
public void testUnrecognizedJava() {
testMojo = new TestMojo("2.1.2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,13 @@ public void testJava20WithSupportedGroovy() {
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

@Test
public void testJava21WithSupportedGroovy() {
testMojo = new TestMojo("4.0.11");
testMojo.targetBytecode = "21";
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

@Test(expected = IllegalArgumentException.class)
public void testUnrecognizedJava() {
testMojo = new TestMojo("2.1.2");
Expand Down

0 comments on commit 5093cfc

Please sign in to comment.