Skip to content

Commit aaf5b4d

Browse files
authored
Fix incompatibility with JUnit 6 in OSGi environment
Change the VersionRange of JUnit platform to support JUnit 6. Fixes #2231
1 parent 4639fff commit aaf5b4d

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

docs/release_notes.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ will now require that the spec is annotated with <<parallel_execution.adoc#isola
5858
=== Misc
5959

6060
* Fix vararg handling in SpyStatic spockIssue:2161[]
61+
* Fix incompatibility with JUnit 6 in OSGi environment spockIssue:2231[]
6162

6263
== 2.4-M6 (2025-04-15)
6364

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ groovy3 = '3.0.25'
55
groovy4 = '4.0.29'
66
jacoco = '0.8.14'
77
junit = '5.14.0'
8+
# The VersionRange used by OSGi to check compatibility with JUnit Platform.
9+
junitPlatformVersionRange = "[1.12,7)"
810
asm = '9.9'
911
mockito4 = '4.11.0'
1012
mockito5 = '5.20.0'

spock-core/core.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,18 @@ tasks.named("jar", Jar) {
6060
'Automatic-Module-Name': 'org.spockframework.core'
6161
)
6262
}
63+
64+
String junitPlatformVersionRange = libs.versions.junitPlatformVersionRange.get()
65+
6366
bundle {
6467
bnd(
6568
'Export-Package': ['org.spockframework.*', 'spock.*'].join(','),
6669
'Import-Package': [
67-
'org.junit.platform.testkit.*;resolution:=optional',
70+
/* We need to override the OSGi version for JUnit platform here, otherwise the version range would be [1.12,2)
71+
* which would exclude JUnit 6 in the OSGi case. Note: JUnit Platform changed the versioning from 1.x to 6.x.
72+
*/
73+
"org.junit.platform.testkit.*;resolution:=optional;version=\"$junitPlatformVersionRange\"",
74+
"org.junit.platform.*;version=\"$junitPlatformVersionRange\"",
6875
'org.hamcrest.*;resolution:=optional',
6976
'org.objenesis.*;resolution:=optional',
7077
'net.bytebuddy.*;resolution:=optional',

0 commit comments

Comments
 (0)