Skip to content

Commit bb3fe0f

Browse files
committed
Default to minimum required Java version for Groovy 5 and 6
Groovy 5 requires Java 11+ and Groovy 6 requires Java 17+. Instead of hardcoding -DjavaVersion in the allVariants scripts (which would override an explicit -DjavaVersion=21 passed by the user), build.gradle now silently defaults to the minimum required Java version when none was specified. An explicit but incompatible javaVersion still fails loudly. allVariants and allVariants.bat use a simple loop over all variants, so e.g. `allVariants -DjavaVersion=21` works correctly for all.
1 parent d046002 commit bb3fe0f

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

allVariants

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
2-
for var in 2.5 3.0 4.0 5.0; do
2+
for var in 2.5 3.0 4.0 5.0 6.0; do
33
./gradlew -Dvariant="$var" "$@"
44
done

allVariants.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
@echo off
2-
for %%v in (2.5 3.0 4.0 5.0) do (
2+
for %%v in (2.5 3.0 4.0 5.0 6.0) do (
33
gradlew.bat -Dvariant=%%v %*
44
)

build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ ext {
5959
minGroovyVersion = "6.0.0"
6060
maxGroovyVersion = "6.9.99"
6161
if (javaVersion < 17) {
62-
throw new InvalidUserDataException("Groovy $variant is not compatible with Java $javaVersion")
62+
if (System.getProperty("javaVersion") != null) {
63+
throw new InvalidUserDataException("Groovy $variant is not compatible with Java $javaVersion")
64+
}
65+
javaVersion = 17
6366
}
6467
} else {
6568
throw new InvalidUserDataException("Unknown variant: $variant. Choose one of: $variants")

0 commit comments

Comments
 (0)