Skip to content

Commit 69ac88d

Browse files
authored
Merge pull request #330 from groovy/java-24
Java 24 & 25 bytecode support
2 parents 156a26f + b28792c commit 69ac88d

File tree

5 files changed

+289
-19
lines changed

5 files changed

+289
-19
lines changed

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
<groupId>org.codehaus.gmavenplus</groupId>
66
<artifactId>gmavenplus-plugin</artifactId>
77
<packaging>maven-plugin</packaging>
8-
<version>4.1.2-SNAPSHOT</version>
8+
<version>4.2.0-SNAPSHOT</version>
99

1010
<properties>
1111
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1212
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
1313
<requiredMavenVersion>3.6.3</requiredMavenVersion>
1414
<mavenVersion>3.9.9</mavenVersion>
15-
<jacocoPluginVersion>0.8.12</jacocoPluginVersion>
15+
<jacocoPluginVersion>0.8.13</jacocoPluginVersion>
1616
<javadocPluginVersion>3.11.2</javadocPluginVersion>
1717
<shortJavaVersion>8</shortJavaVersion>
1818
<!-- these are properties so integration tests can use them -->
@@ -21,7 +21,7 @@
2121
<compilerPluginVersion>3.13.0</compilerPluginVersion>
2222
<resourcesPluginVersion>3.3.1</resourcesPluginVersion>
2323
<junitVersion>4.13.2</junitVersion>
24-
<surefirePluginVersion>3.5.2</surefirePluginVersion>
24+
<surefirePluginVersion>3.5.3</surefirePluginVersion>
2525
<pluginPluginVersion>3.15.1</pluginPluginVersion>
2626
<!-- this is a property so that site generation can use it -->
2727
<sourcePluginVersion>3.3.1</sourcePluginVersion>
@@ -211,7 +211,7 @@
211211
<dependency>
212212
<groupId>org.codehaus.mojo</groupId>
213213
<artifactId>extra-enforcer-rules</artifactId>
214-
<version>1.9.0</version>
214+
<version>1.10.0</version>
215215
</dependency>
216216
</dependencies>
217217
</plugin>

src/main/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojo.java

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,43 @@
4444
*/
4545
public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo {
4646

47+
/**
48+
* Groovy 5.0.0-alpha-13 version.
49+
*/
50+
protected static final Version GROOVY_5_0_0_ALPHA13 = new Version(5, 0, 0, "alpha-13");
51+
52+
/**
53+
* Groovy 5.0.0-alpha-11 version.
54+
*/
55+
protected static final Version GROOVY_5_0_0_ALPHA11 = new Version(5, 0, 0, "alpha-11");
56+
57+
/**
58+
* Groovy 5.0.0-alpha-8 version.
59+
*/
60+
protected static final Version GROOVY_5_0_0_ALPHA8 = new Version(5, 0, 0, "alpha-8");
61+
62+
/**
63+
* Groovy 5.0.0-alpha-3 version.
64+
*/
65+
protected static final Version GROOVY_5_0_0_ALPHA3 = new Version(5, 0, 0, "alpha-3");
66+
4767
/**
4868
* Groovy 5.0.0-alpha-1 version.
4969
*/
5070
protected static final Version GROOVY_5_0_0_ALPHA1 = new Version(5, 0, 0, "alpha-1");
5171

5272
/**
53-
* Groovy 4.0.11 version.
73+
* Groovy 4.0.27 version.
74+
*/
75+
protected static final Version GROOVY_4_0_27 = new Version(4, 0, 27);
76+
77+
/**
78+
* Groovy 4.0.24 version.
79+
*/
80+
protected static final Version GROOVY_4_0_24 = new Version(4, 0, 24);
81+
82+
/**
83+
* Groovy 4.0.21 version.
5484
*/
5585
protected static final Version GROOVY_4_0_21 = new Version(4, 0, 21);
5686

@@ -213,6 +243,8 @@ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo {
213243
* <li>21</li>
214244
* <li>22</li>
215245
* <li>23</li>
246+
* <li>24</li>
247+
* <li>25</li>
216248
* </ul>
217249
* Using 1.6 (or 6) or 1.7 (or 7) requires Groovy &gt;= 2.1.3.
218250
* Using 1.8 (or 8) requires Groovy &gt;= 2.3.3.
@@ -228,8 +260,10 @@ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo {
228260
* Using 19 requires Groovy &gt; 4.0.2.
229261
* Using 20 requires Groovy &gt; 4.0.6.
230262
* Using 21 requires Groovy &gt; 4.0.11.
231-
* Using 22 requires Groovy &gt; 4.0.16.
232-
* Using 23 requires Groovy &gt; 4.0.21.
263+
* Using 22 requires Groovy &gt; 4.0.16 or Groovy &gt; 5.0.0-alpha-3.
264+
* Using 23 requires Groovy &gt; 4.0.21 or Groovy &gt; 5.0.0-alpha-8.
265+
* Using 24 requires Groovy &gt; 4.0.24 or Groovy &gt; 5.0.0-alpha-11.
266+
* Using 25 requires Groovy &gt; 4.0.27 or Groovy &gt; 5.0.0-alpha-13.
233267
*/
234268
@Parameter(property = "maven.compiler.target", defaultValue = "1.8")
235269
protected String targetBytecode;
@@ -526,14 +560,34 @@ protected void verifyGroovyVersionSupportsTargetBytecode() {
526560
}
527561
}
528562

529-
if ("23".equals(targetBytecode)) {
563+
if ("25".equals(targetBytecode)) {
564+
if (groovyOlderThan(GROOVY_4_0_27)) {
565+
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_24 + " or newer.");
566+
}
567+
if (groovyNewerThan(GROOVY_5_0_0_ALPHA1) && groovyOlderThan(GROOVY_5_0_0_ALPHA13)) {
568+
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_5_0_0_ALPHA13 + " or newer.");
569+
}
570+
} else if ("24".equals(targetBytecode)) {
571+
if (groovyOlderThan(GROOVY_4_0_24)) {
572+
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_24 + " or newer.");
573+
}
574+
if (groovyNewerThan(GROOVY_5_0_0_ALPHA1) && groovyOlderThan(GROOVY_5_0_0_ALPHA11)) {
575+
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_5_0_0_ALPHA11 + " or newer.");
576+
}
577+
} else if ("23".equals(targetBytecode)) {
530578
if (groovyOlderThan(GROOVY_4_0_21)) {
531579
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_21 + " or newer.");
532580
}
581+
if (groovyNewerThan(GROOVY_5_0_0_ALPHA1) && groovyOlderThan(GROOVY_5_0_0_ALPHA8)) {
582+
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_5_0_0_ALPHA8 + " or newer.");
583+
}
533584
} else if ("22".equals(targetBytecode)) {
534585
if (groovyOlderThan(GROOVY_4_0_16)) {
535586
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_16 + " or newer.");
536587
}
588+
if (groovyNewerThan(GROOVY_5_0_0_ALPHA1) && groovyOlderThan(GROOVY_5_0_0_ALPHA3)) {
589+
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_5_0_0_ALPHA3 + " or newer.");
590+
}
537591
} else if ("21".equals(targetBytecode)) {
538592
if (groovyOlderThan(GROOVY_4_0_11)) {
539593
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_11 + " or newer.");

src/main/java/org/codehaus/gmavenplus/mojo/AbstractGenerateStubsMojo.java

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,43 @@
4646
*/
4747
public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSourcesMojo {
4848

49+
/**
50+
* Groovy 5.0.0-alpha-13 version.
51+
*/
52+
protected static final Version GROOVY_5_0_0_ALPHA13 = new Version(5, 0, 0, "alpha-13");
53+
54+
/**
55+
* Groovy 5.0.0-alpha-11 version.
56+
*/
57+
protected static final Version GROOVY_5_0_0_ALPHA11 = new Version(5, 0, 0, "alpha-11");
58+
59+
/**
60+
* Groovy 5.0.0-alpha-8 version.
61+
*/
62+
protected static final Version GROOVY_5_0_0_ALPHA8 = new Version(5, 0, 0, "alpha-8");
63+
64+
/**
65+
* Groovy 5.0.0-alpha-3 version.
66+
*/
67+
protected static final Version GROOVY_5_0_0_ALPHA3 = new Version(5, 0, 0, "alpha-3");
68+
4969
/**
5070
* Groovy 5.0.0-alpha-1 version.
5171
*/
5272
protected static final Version GROOVY_5_0_0_ALPHA1 = new Version(5, 0, 0, "alpha-1");
5373

5474
/**
55-
* Groovy 4.0.11 version.
75+
* Groovy 4.0.27 version.
76+
*/
77+
protected static final Version GROOVY_4_0_27 = new Version(4, 0, 27);
78+
79+
/**
80+
* Groovy 4.0.24 version.
81+
*/
82+
protected static final Version GROOVY_4_0_24 = new Version(4, 0, 24);
83+
84+
/**
85+
* Groovy 4.0.21 version.
5686
*/
5787
protected static final Version GROOVY_4_0_21 = new Version(4, 0, 21);
5888

@@ -210,6 +240,8 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource
210240
* <li>21</li>
211241
* <li>22</li>
212242
* <li>23</li>
243+
* <li>24</li>
244+
* <li>25</li>
213245
* </ul>
214246
* Using 1.6 (or 6) or 1.7 (or 7) requires Groovy &gt;= 2.1.3.
215247
* Using 1.8 (or 8) requires Groovy &gt;= 2.3.3.
@@ -225,8 +257,10 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource
225257
* Using 19 requires Groovy &gt; 4.0.2.
226258
* Using 20 requires Groovy &gt; 4.0.6.
227259
* Using 21 requires Groovy &gt; 4.0.11.
228-
* Using 22 requires Groovy &gt; 4.0.16.
229-
* Using 23 requires Groovy &gt; 4.0.21.
260+
* Using 22 requires Groovy &gt; 4.0.16 or Groovy &gt; 5.0.0-alpha-3.
261+
* Using 23 requires Groovy &gt; 4.0.21 or Groovy &gt; 5.0.0-alpha-8.
262+
* Using 24 requires Groovy &gt; 4.0.24 or Groovy &gt; 5.0.0-alpha-11.
263+
* Using 25 requires Groovy &gt; 4.0.27 or Groovy &gt; 5.0.0-alpha-13.
230264
*
231265
* @since 1.0-beta-3
232266
*/
@@ -447,14 +481,34 @@ protected void verifyGroovyVersionSupportsTargetBytecode() {
447481
}
448482
}
449483

450-
if ("23".equals(targetBytecode)) {
484+
if ("25".equals(targetBytecode)) {
485+
if (groovyOlderThan(GROOVY_4_0_27)) {
486+
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_24 + " or newer.");
487+
}
488+
if (groovyNewerThan(GROOVY_5_0_0_ALPHA1) && groovyOlderThan(GROOVY_5_0_0_ALPHA13)) {
489+
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_5_0_0_ALPHA13 + " or newer.");
490+
}
491+
} else if ("24".equals(targetBytecode)) {
492+
if (groovyOlderThan(GROOVY_4_0_24)) {
493+
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_24 + " or newer.");
494+
}
495+
if (groovyNewerThan(GROOVY_5_0_0_ALPHA1) && groovyOlderThan(GROOVY_5_0_0_ALPHA11)) {
496+
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_5_0_0_ALPHA11 + " or newer.");
497+
}
498+
} else if ("23".equals(targetBytecode)) {
451499
if (groovyOlderThan(GROOVY_4_0_21)) {
452500
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_21 + " or newer.");
453501
}
502+
if (groovyNewerThan(GROOVY_5_0_0_ALPHA1) && groovyOlderThan(GROOVY_5_0_0_ALPHA8)) {
503+
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_5_0_0_ALPHA8 + " or newer.");
504+
}
454505
} else if ("22".equals(targetBytecode)) {
455506
if (groovyOlderThan(GROOVY_4_0_16)) {
456507
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_16 + " or newer.");
457508
}
509+
if (groovyNewerThan(GROOVY_5_0_0_ALPHA1) && groovyOlderThan(GROOVY_5_0_0_ALPHA3)) {
510+
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_5_0_0_ALPHA3 + " or newer.");
511+
}
458512
} else if ("21".equals(targetBytecode)) {
459513
if (groovyOlderThan(GROOVY_4_0_11)) {
460514
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_11 + " or newer.");
@@ -517,13 +571,7 @@ protected void verifyGroovyVersionSupportsTargetBytecode() {
517571
}
518572

519573
protected static String translateJavacTargetToTargetBytecode(String targetBytecode) {
520-
Map<String, String> javacTargetToTargetBytecode = new HashMap<>();
521-
javacTargetToTargetBytecode.put("5", "1.5");
522-
javacTargetToTargetBytecode.put("6", "1.6");
523-
javacTargetToTargetBytecode.put("7", "1.7");
524-
javacTargetToTargetBytecode.put("8", "1.8");
525-
javacTargetToTargetBytecode.put("1.9", "9");
526-
return javacTargetToTargetBytecode.getOrDefault(targetBytecode, targetBytecode);
574+
return AbstractCompileMojo.translateJavacTargetToTargetBytecode(targetBytecode);
527575
}
528576

529577
}

src/test/java/org/codehaus/gmavenplus/mojo/AbstractCompileMojoTest.java

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,20 @@ public void testJava22WithSupportedGroovy() {
430430
testMojo.verifyGroovyVersionSupportsTargetBytecode();
431431
}
432432

433+
@Test(expected = IllegalArgumentException.class)
434+
public void testJava22WithUnsupportedGroovy5() {
435+
testMojo = new TestMojo("5.0.0-alpha-2");
436+
testMojo.targetBytecode = "22";
437+
testMojo.verifyGroovyVersionSupportsTargetBytecode();
438+
}
439+
440+
@Test
441+
public void testJava22WithSupportedGroovy5() {
442+
testMojo = new TestMojo("5.0.0-alpha-3");
443+
testMojo.targetBytecode = "22";
444+
testMojo.verifyGroovyVersionSupportsTargetBytecode();
445+
}
446+
433447
@Test(expected = IllegalArgumentException.class)
434448
public void testJava23WithUnsupportedGroovy() {
435449
testMojo = new TestMojo("4.0.20");
@@ -444,6 +458,76 @@ public void testJava23WithSupportedGroovy() {
444458
testMojo.verifyGroovyVersionSupportsTargetBytecode();
445459
}
446460

461+
@Test(expected = IllegalArgumentException.class)
462+
public void testJava23WithUnsupportedGroovy5() {
463+
testMojo = new TestMojo("5.0.0-alpha-7");
464+
testMojo.targetBytecode = "23";
465+
testMojo.verifyGroovyVersionSupportsTargetBytecode();
466+
}
467+
468+
@Test
469+
public void testJava23WithSupportedGroovy5() {
470+
testMojo = new TestMojo("5.0.0-alpha-8");
471+
testMojo.targetBytecode = "23";
472+
testMojo.verifyGroovyVersionSupportsTargetBytecode();
473+
}
474+
475+
@Test(expected = IllegalArgumentException.class)
476+
public void testJava24WithUnsupportedGroovy() {
477+
testMojo = new TestMojo("4.0.23");
478+
testMojo.targetBytecode = "24";
479+
testMojo.verifyGroovyVersionSupportsTargetBytecode();
480+
}
481+
482+
@Test
483+
public void testJava24WithSupportedGroovy() {
484+
testMojo = new TestMojo("4.0.24");
485+
testMojo.targetBytecode = "24";
486+
testMojo.verifyGroovyVersionSupportsTargetBytecode();
487+
}
488+
489+
@Test(expected = IllegalArgumentException.class)
490+
public void testJava24WithUnsupportedGroovy5() {
491+
testMojo = new TestMojo("5.0.0-alpha-10");
492+
testMojo.targetBytecode = "24";
493+
testMojo.verifyGroovyVersionSupportsTargetBytecode();
494+
}
495+
496+
@Test
497+
public void testJava24WithSupportedGroovy5() {
498+
testMojo = new TestMojo("5.0.0-alpha-11");
499+
testMojo.targetBytecode = "24";
500+
testMojo.verifyGroovyVersionSupportsTargetBytecode();
501+
}
502+
503+
@Test(expected = IllegalArgumentException.class)
504+
public void testJava25WithUnsupportedGroovy() {
505+
testMojo = new TestMojo("4.0.26");
506+
testMojo.targetBytecode = "25";
507+
testMojo.verifyGroovyVersionSupportsTargetBytecode();
508+
}
509+
510+
@Test
511+
public void testJava25WithSupportedGroovy() {
512+
testMojo = new TestMojo("4.0.27");
513+
testMojo.targetBytecode = "25";
514+
testMojo.verifyGroovyVersionSupportsTargetBytecode();
515+
}
516+
517+
@Test(expected = IllegalArgumentException.class)
518+
public void testJava25WithUnsupportedGroovy5() {
519+
testMojo = new TestMojo("5.0.0-alpha-12");
520+
testMojo.targetBytecode = "25";
521+
testMojo.verifyGroovyVersionSupportsTargetBytecode();
522+
}
523+
524+
@Test
525+
public void testJava25WithSupportedGroovy5() {
526+
testMojo = new TestMojo("5.0.0-alpha-13");
527+
testMojo.targetBytecode = "25";
528+
testMojo.verifyGroovyVersionSupportsTargetBytecode();
529+
}
530+
447531
@Test(expected = IllegalArgumentException.class)
448532
public void testUnrecognizedJava() {
449533
testMojo = new TestMojo("2.1.2");

0 commit comments

Comments
 (0)