Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Java 22 and 23 #302

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading