Skip to content

Commit 50e0bab

Browse files
committed
Add Groovy 5 support (#2196)
1 parent 8478ba1 commit 50e0bab

33 files changed

+652
-56
lines changed

.github/codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ codecov:
33

44
comment:
55
layout: "reach, diff, flags, files"
6-
after_n_builds: 18
6+
after_n_builds: 24

.github/renovate.json5

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
matchCurrentValue: "/^4\\./",
2121
allowedVersions: "(,5.0)"
2222
},
23+
{
24+
matchPackageNames: ["/^org.apache.groovy:/"],
25+
matchCurrentValue: "/^5\\./",
26+
allowedVersions: "(,6.0)"
27+
},
2328
{
2429
matchPackageNames: ["/^org.mockito:/"],
2530
matchCurrentValue: "/^4\\./",
@@ -34,6 +39,11 @@
3439
matchPackageNames: ["/^org.spockframework:spock-/"],
3540
matchCurrentVersion: "/-groovy-4\\.0$/",
3641
allowedVersions: "/-groovy-4\\.0$/"
42+
},
43+
{
44+
matchPackageNames: ["/^org.spockframework:spock-/"],
45+
matchCurrentVersion: "/-groovy-5\\.0$/",
46+
allowedVersions: "/-groovy-5\\.0$/"
3747
}
3848
]
3949
}

.github/workflows/branches-and-prs.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
- '2.5'
5757
- '3.0'
5858
- '4.0'
59+
- '5.0'
5960
java:
6061
- '8'
6162
- '11'
@@ -74,6 +75,9 @@ jobs:
7475
- variant: '2.5'
7576
java: '24'
7677
os: 'ubuntu-latest'
78+
- variant: '5.0'
79+
java: '8'
80+
os: 'ubuntu-latest'
7781
include:
7882
- variant: '2.5'
7983
java: '8'
@@ -84,6 +88,9 @@ jobs:
8488
- variant: '4.0'
8589
java: '8'
8690
os: 'windows-latest'
91+
- variant: '5.0'
92+
java: '11'
93+
os: 'windows-latest'
8794
- variant: '2.5'
8895
java: '8'
8996
os: 'macos-latest'
@@ -93,6 +100,9 @@ jobs:
93100
- variant: '4.0'
94101
java: '8'
95102
os: 'macos-latest'
103+
- variant: '5.0'
104+
java: '11'
105+
os: 'macos-latest'
96106
steps:
97107
- id: 'step-0'
98108
name: 'Checkout Repository'

.github/workflows/codeql-analysis.main.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ workflow(
125125
"--stacktrace",
126126
"--no-build-cache",
127127
"testClasses",
128-
""""-Dvariant=${expr(Matrix.variant)}""""
128+
""""-Dvariant=${expr(Matrix.variant)}"""",
129+
""""-DjavaVersion=${expr("${Matrix.variant} == '5.0' && '11' || '${Matrix.axes.javaVersions.first()}'")}""""
129130
).joinToString(" ")
130131
)
131132
uses(

.github/workflows/codeql-analysis.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
- '2.5'
4141
- '3.0'
4242
- '4.0'
43+
- '5.0'
4344
steps:
4445
- id: 'step-0'
4546
name: 'Checkout Repository'
@@ -52,7 +53,7 @@ jobs:
5253
uses: 'github/codeql-action/init@v3'
5354
- id: 'step-3'
5455
name: 'Build Spock Classes'
55-
run: './gradlew --stacktrace --no-build-cache testClasses "-Dvariant=${{ matrix.variant }}"'
56+
run: './gradlew --stacktrace --no-build-cache testClasses "-Dvariant=${{ matrix.variant }}" "-DjavaVersion=${{ matrix.variant == ''5.0'' && ''11'' || ''8'' }}"'
5657
- id: 'step-4'
5758
name: 'Perform CodeQL Analysis'
5859
uses: 'github/codeql-action/analyze@v3'

.github/workflows/common.main.kts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,20 @@ val Matrix.Companion.full
139139
operatingSystems = listOf("ubuntu-latest"),
140140
variants = axes.variants,
141141
javaVersions = axes.javaVersions + axes.additionalJavaTestVersions,
142-
exclude = { (variant == "2.5") && (javaVersion!!.toInt() >= 17) },
142+
exclude = {
143+
((variant == "2.5") && (javaVersion!!.toInt() >= 17)) ||
144+
((variant == "5.0") && (javaVersion!!.toInt() < 11))
145+
},
143146
includes = listOf("windows-latest", "macos-latest")
144-
.map {
145-
Matrix.Element(
146-
operatingSystem = it,
147-
javaVersion = axes.javaVersions.first()
148-
)
147+
.map { Matrix.Element(operatingSystem = it) }
148+
.flatMap { element ->
149+
axes.variants.map {
150+
element.copy(
151+
variant = it,
152+
javaVersion = if (it == "5.0") "11" else axes.javaVersions.first()
153+
)
154+
}
149155
}
150-
.flatMap { element -> axes.variants.map { element.copy(variant = it) } }
151156
)
152157

153158
val Matrix.Companion.axes by lazy {

.github/workflows/docs-pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
run: 'sudo apt update && sudo apt install --yes graphviz'
4949
- id: 'step-3'
5050
name: 'Build Docs'
51-
run: './gradlew --stacktrace asciidoctor javadoc "-Dvariant=4.0" "-DjavaVersion=21"'
51+
run: './gradlew --stacktrace asciidoctor javadoc "-Dvariant=5.0" "-DjavaVersion=21"'
5252
- id: 'step-4'
5353
name: 'Archive and upload docs'
5454
uses: 'actions/upload-artifact@v4'

.github/workflows/release.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
- '2.5'
3737
- '3.0'
3838
- '4.0'
39+
- '5.0'
3940
java:
4041
- '8'
4142
- '11'
@@ -54,6 +55,9 @@ jobs:
5455
- variant: '2.5'
5556
java: '24'
5657
os: 'ubuntu-latest'
58+
- variant: '5.0'
59+
java: '8'
60+
os: 'ubuntu-latest'
5761
include:
5862
- variant: '2.5'
5963
java: '8'
@@ -64,6 +68,9 @@ jobs:
6468
- variant: '4.0'
6569
java: '8'
6670
os: 'windows-latest'
71+
- variant: '5.0'
72+
java: '11'
73+
os: 'windows-latest'
6774
- variant: '2.5'
6875
java: '8'
6976
os: 'macos-latest'
@@ -73,6 +80,9 @@ jobs:
7380
- variant: '4.0'
7481
java: '8'
7582
os: 'macos-latest'
83+
- variant: '5.0'
84+
java: '11'
85+
os: 'macos-latest'
7686
steps:
7787
- id: 'step-0'
7888
name: 'Checkout Repository'
@@ -109,6 +119,7 @@ jobs:
109119
- '2.5'
110120
- '3.0'
111121
- '4.0'
122+
- '5.0'
112123
java:
113124
- '8'
114125
os:
@@ -140,7 +151,7 @@ jobs:
140151
strategy:
141152
matrix:
142153
variant:
143-
- '4.0'
154+
- '5.0'
144155
java:
145156
- '21'
146157
os:

CONTRIBUTING.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ Functional tests for `spock-core` are located under https://github.spockframewor
137137
=== Command Line Build
138138

139139
Spock is built with https://www.gradle.org[Gradle].
140-
The only prerequisite for executing the build is an installation of JDK 8 and JDK 17.
141-
The build itself must be run with JDK 17, but JDK 8 must be available via toolchain.
140+
The only prerequisite for executing the build is an installation of JDK 11 and JDK 17.
141+
The build itself must be run with JDK 17, but JDK 11 must be available via toolchain.
142142
You can check if Gradle can locate the necessary JDKs by running `./gradlew javaToolchains`.
143-
If gradle can't locate your JDK 8, you can make the location of the JDK 8 available via an environment variable called `JDK8`.
143+
If Gradle can't locate your JDK 11, you can make the location of the JDK 11 available via an environment variable called `JDK11`.
144144

145145
After cloning the https://github.com/spockframework/spock[GitHub repository], cd into the top directory and execute `./gradlew build`. The build should succeed without any errors. `./gradlew tasks` lists the available tasks.
146146
Always use the Gradle Wrapper (`gradlew` command) rather than your own Gradle installation.

README.adoc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ https://groovyconsole.dev/[Groovy Web Console].
2929
* The latest 2.x release version is *{spock-release-version}* ({spock-release-version}-groovy-2.5,
3030
{spock-release-version}-groovy-3.0, {spock-release-version}-groovy-4.0), released on {spock-release-date}.
3131
* The current development version is *{spock-snapshot-version}-SNAPSHOT*
32-
({spock-snapshot-version}-groovy-2.5-SNAPSHOT, {spock-snapshot-version}-groovy-3.0-SNAPSHOT, {spock-snapshot-version}-groovy-4.0-SNAPSHOT).
32+
({spock-snapshot-version}-groovy-2.5-SNAPSHOT, {spock-snapshot-version}-groovy-3.0-SNAPSHOT,
33+
{spock-snapshot-version}-groovy-4.0-SNAPSHOT), {spock-snapshot-version}-groovy-5.0-SNAPSHOT).
3334

3435
*NOTE:* Spock 2.x is based on the JUnit 5 Platform and requires Java
35-
8+/groovy-2.5+ (Groovy 3.0 or 4.0 is recommended, especially in projects using
36+
8+/groovy-2.5+ (Groovy 3.0 or newer is recommended, especially in projects using
3637
Java 12+).
3738

3839
Releases are available from
@@ -86,25 +87,26 @@ https://tapestry.apache.org/[Tapestry 5] IoC container.
8687

8788
==== Prerequisites
8889

89-
Spock needs both a JDK 8 and JDK 17+ installed.
90+
Spock needs both a JDK 11 and JDK 17+ installed.
9091

91-
* JDK 8 is required to compile Spock via toolchains (automatic download is disabled).
92+
* JDK 11 is required to compile Spock via toolchains (automatic download is disabled).
9293
* The gradle build itself requires at least JDK 17 to run.
9394

9495
JDK locations must be made known to toolchains via `JDK<version>=<PATH>` environment
95-
variable, e.g., `JDK8=/path/to/jdk8`.
96+
variable if they are not in standard places recognized by Gradle, e.g. `JDK11=/path/to/jdk11`.
9697

9798
==== Supported versions
9899

99100
Spock is supported for Java version 8+.
100101

101-
Spock is supported for Groovy versions 2.5, 3.0, and 4.0.
102+
Spock is supported for Groovy versions 2.5, 3.0, 4.0, and 5.0.
102103

103104
The tests are testing Spock with the specific versions (variants) of
104105
Groovy and Java. Default Groovy version is 2.5.
105106

106107
The Groovy 3.0 and 4.0 variant should pass on all supported JDK versions,
107108
Groovy 2.5 does not work with Java 17+:
109+
Groovy 5.0 and newer does not work with Java <11:
108110

109111
....
110112
./gradlew build

0 commit comments

Comments
 (0)