Skip to content

Commit 4b0ce34

Browse files
committed
Make Spock version conditional based on Gradle version
- Use Spock 2.3-groovy-3.0 for Gradle 8.x (Groovy 3.0.x) - Use Spock 2.3-groovy-4.0 for Gradle 9.x (Groovy 4.0.x) - Tests now compile and run with both Gradle 8 and Gradle 9 - Fixes IncompatibleGroovyVersionException on Gradle 8
1 parent ffec9f5 commit 4b0ce34

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

build.gradle

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ dependencies {
2323
// JUnit 4 for JUnit-based tests (NuGetPluginTest, etc.)
2424
testImplementation 'junit:junit:4.13.2'
2525
// Groovy test support (GroovyTestCase, etc.) - use same version as Gradle's bundled Groovy
26-
// Gradle 9.2.1 uses Groovy 4.0.28, but we should use localGroovy() for test dependencies too
2726
testImplementation localGroovy()
28-
// Spock version selection: Use 2.3-groovy-4.0 for Groovy 4.0 compatibility (Gradle 9.2.1)
29-
// Note: This may not work with Gradle 8.3 (Groovy 3.0.x) - may need conditional version
30-
// For now, prioritize Gradle 9.2.1 compatibility
31-
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
27+
28+
// Spock version selection based on Gradle version:
29+
// - Gradle 8.x uses Groovy 3.0.x -> Spock 2.3-groovy-3.0
30+
// - Gradle 9.x uses Groovy 4.0.x -> Spock 2.3-groovy-4.0
31+
def spockVersion = project.gradle.gradleVersion.startsWith('9.')
32+
? '2.3-groovy-4.0'
33+
: '2.3-groovy-3.0'
34+
testImplementation "org.spockframework:spock-core:${spockVersion}"
3235
}
3336

3437

0 commit comments

Comments
 (0)