Skip to content

Commit

Permalink
Merge pull request #302 from groovy/java_22_23
Browse files Browse the repository at this point in the history
Support Java 22 and 23
  • Loading branch information
keeganwitt authored May 18, 2024
2 parents 02d3f3a + 48f26b9 commit f407028
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo {
*/
protected static final Version GROOVY_5_0_0_ALPHA1 = new Version(5, 0, 0, "alpha-1");

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

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

/**
* Groovy 4.0.11 version.
*/
Expand Down Expand Up @@ -198,6 +208,11 @@ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo {
* <li>16</li>
* <li>17</li>
* <li>18</li>
* <li>19</li>
* <li>20</li>
* <li>21</li>
* <li>22</li>
* <li>23</li>
* </ul>
* Using 1.6 (or 6) or 1.7 (or 7) requires Groovy &gt;= 2.1.3.
* Using 1.8 (or 8) requires Groovy &gt;= 2.3.3.
Expand All @@ -213,6 +228,8 @@ public abstract class AbstractCompileMojo extends AbstractGroovySourcesMojo {
* Using 19 requires Groovy &gt; 4.0.2.
* Using 20 requires Groovy &gt; 4.0.6.
* Using 21 requires Groovy &gt; 4.0.11.
* Using 22 requires Groovy &gt; 4.0.16.
* Using 23 requires Groovy &gt; 4.0.21.
*/
@Parameter(property = "maven.compiler.target", defaultValue = "1.8")
protected String targetBytecode;
Expand Down Expand Up @@ -509,7 +526,15 @@ protected void verifyGroovyVersionSupportsTargetBytecode() {
}
}

if ("21".equals(targetBytecode)) {
if ("23".equals(targetBytecode)) {
if (groovyOlderThan(GROOVY_4_0_21)) {
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_21 + " or newer.");
}
} else if ("22".equals(targetBytecode)) {
if (groovyOlderThan(GROOVY_4_0_16)) {
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_16 + " or newer.");
}
} else if ("21".equals(targetBytecode)) {
if (groovyOlderThan(GROOVY_4_0_11)) {
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_11 + " or newer.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource
*/
protected static final Version GROOVY_5_0_0_ALPHA1 = new Version(5, 0, 0, "alpha-1");

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

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

/**
* Groovy 4.0.11 version.
*/
Expand Down Expand Up @@ -195,6 +205,11 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource
* <li>16</li>
* <li>17</li>
* <li>18</li>
* <li>19</li>
* <li>20</li>
* <li>21</li>
* <li>22</li>
* <li>23</li>
* </ul>
* Using 1.6 (or 6) or 1.7 (or 7) requires Groovy &gt;= 2.1.3.
* Using 1.8 (or 8) requires Groovy &gt;= 2.3.3.
Expand All @@ -210,6 +225,8 @@ public abstract class AbstractGenerateStubsMojo extends AbstractGroovyStubSource
* Using 19 requires Groovy &gt; 4.0.2.
* Using 20 requires Groovy &gt; 4.0.6.
* Using 21 requires Groovy &gt; 4.0.11.
* Using 22 requires Groovy &gt; 4.0.16.
* Using 23 requires Groovy &gt; 4.0.21.
*
* @since 1.0-beta-3
*/
Expand Down Expand Up @@ -430,7 +447,15 @@ protected void verifyGroovyVersionSupportsTargetBytecode() {
}
}

if ("21".equals(targetBytecode)) {
if ("23".equals(targetBytecode)) {
if (groovyOlderThan(GROOVY_4_0_21)) {
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_21 + " or newer.");
}
} else if ("22".equals(targetBytecode)) {
if (groovyOlderThan(GROOVY_4_0_16)) {
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_16 + " or newer.");
}
} else if ("21".equals(targetBytecode)) {
if (groovyOlderThan(GROOVY_4_0_11)) {
throw new IllegalArgumentException("Target bytecode " + targetBytecode + " requires Groovy " + GROOVY_4_0_11 + " or newer.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,48 @@ public void testJava20WithSupportedGroovy() {
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

@Test(expected = IllegalArgumentException.class)
public void testJava21WithUnsupportedGroovy() {
testMojo = new TestMojo("4.0.10");
testMojo.targetBytecode = "21";
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

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

@Test(expected = IllegalArgumentException.class)
public void testJava22WithUnsupportedGroovy() {
testMojo = new TestMojo("4.0.15");
testMojo.targetBytecode = "22";
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

@Test
public void testJava22WithSupportedGroovy() {
testMojo = new TestMojo("4.0.16");
testMojo.targetBytecode = "22";
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

@Test(expected = IllegalArgumentException.class)
public void testJava23WithUnsupportedGroovy() {
testMojo = new TestMojo("4.0.20");
testMojo.targetBytecode = "23";
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

@Test
public void testJava23WithSupportedGroovy() {
testMojo = new TestMojo("4.0.21");
testMojo.targetBytecode = "23";
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,13 +432,48 @@ public void testJava20WithSupportedGroovy() {
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

@Test(expected = IllegalArgumentException.class)
public void testJava21WithUnsupportedGroovy() {
testMojo = new TestMojo("4.0.10");
testMojo.targetBytecode = "21";
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

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

@Test(expected = IllegalArgumentException.class)
public void testJava22WithUnsupportedGroovy() {
testMojo = new TestMojo("4.0.15");
testMojo.targetBytecode = "22";
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

@Test
public void testJava22WithSupportedGroovy() {
testMojo = new TestMojo("4.0.16");
testMojo.targetBytecode = "22";
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

@Test(expected = IllegalArgumentException.class)
public void testJava23WithUnsupportedGroovy() {
testMojo = new TestMojo("4.0.20");
testMojo.targetBytecode = "23";
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

@Test
public void testJava23WithSupportedGroovy() {
testMojo = new TestMojo("4.0.21");
testMojo.targetBytecode = "23";
testMojo.verifyGroovyVersionSupportsTargetBytecode();
}

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

0 comments on commit f407028

Please sign in to comment.