Skip to content

Update Spock to 2.4-groovy-4.0 and align test dependencies#15703

Open
jamesfredley wants to merge 3 commits into
8.0.xfrom
deps/spock-2.4
Open

Update Spock to 2.4-groovy-4.0 and align test dependencies#15703
jamesfredley wants to merge 3 commits into
8.0.xfrom
deps/spock-2.4

Conversation

@jamesfredley
Copy link
Copy Markdown
Contributor

@jamesfredley jamesfredley commented May 29, 2026

What

Upgrades Spock from 2.3-groovy-4.0 to the latest stable 2.4-groovy-4.0 on the 8.0.x branch, pulls in the new dependency Spock 2.4 requires, and adapts the framework tests to Spock 2.4's stricter behavior.

Dependency Before After Notes
spock.version 2.3-groovy-4.0 2.4-groovy-4.0 latest stable for Groovy 4.0 (there is no 2.5)
gradle-spock.version 2.3-groovy-4.0 2.4-groovy-4.0 build-logic + grails-gradle
grails-forge spockVersion 2.3-groovy-4.0 2.4-groovy-4.0 grails-forge's own tests
geantyref.version - 1.3.16 new - required by Spock 2.4 mocking (see below)

Evaluated but deliberately left unchanged:

  • Selenium stays at 4.38.0. Bumping it drags OpenTelemetry above Spring Boot 4.0.6's managed 1.55.0 (selenium 4.38.0 → otel 1.55.0, but 4.44.01.62.0), which fails the validateDependencyVersions gate. 4.38.0 is the release whose OpenTelemetry matches Boot, so it is the correct pin.
  • geb-spock (8.0.1) is already the latest release.
  • JUnit (6.0.3) already matches Boot's managed junit-jupiter; byte-buddy (1.18.8) keeps its existing override; objenesis (3.4) is already latest.

New geantyref dependency

Spock 2.4 replaced its bundled gentyref code with io.leangen.geantyref:geantyref:1.3.16, declared in spock-core as a required runtime dependency and used by the mocking engine (GenericTypeReflectorUtil). Modules that declare spock-core with transitive = false (and therefore re-add byte-buddy/objenesis for mocking) must also add geantyref, otherwise Mock()/Stub()/Spy() fail at runtime with:

java.lang.NoClassDefFoundError: io/leangen/geantyref/GenericTypeReflector

This PR adds geantyref to the BOM and declares it next to byte-buddy/objenesis in every module that strips Spock's transitives.

Generated applications need no change. grails-forge and grails-profiles declare spock-core transitively, so geantyref arrives automatically at the version managed by grails-bom - no generator or skeleton template change is required.

Spock 2.4 test compatibility

Spock 2.4 tightened two behaviors that existing tests relied on:

Stale Spock version references in AGENTS.md and a settings.gradle comment were also refreshed.

Verification

grails-bootstrap, grails-web-mvc, grails-views-gson, and grails-datamapping-core tests pass locally, along with :grails-gradle-model:test and validateDependencyVersions. CI exercises the full module matrix, the separate grails-gradle build, and grails-forge.

Upgrade Spock from 2.3-groovy-4.0 to the latest stable 2.4-groovy-4.0
(both spock.version and gradle-spock.version), and bump selenium-bom from
4.38.0 to 4.44.0 for the Geb functional tests. JUnit (6.0.3) already
matches Spring Boot's managed junit-jupiter, byte-buddy (1.18.8) keeps its
existing deliberate override, and objenesis (3.4) and geb-spock (8.0.1)
are already at their latest, so they are left unchanged.

Spock 2.4 introduces a new required runtime dependency,
io.leangen.geantyref:geantyref:1.3.16, used by its mocking engine
(GenericTypeReflectorUtil). Modules that declare spock-core with
`transitive = false` strip this dependency, which breaks mock creation.
geantyref is therefore:

- added to the BOM (gradleBomDependencies) so it is version-managed and
  flows transitively to consumers and generated applications, and
- declared explicitly next to byte-buddy/objenesis in every framework
  module that strips Spock's transitives.

Generated applications (grails-forge and grails-profiles) declare
spock-core transitively, so they receive geantyref automatically at the
BOM-managed version - no generator/template changes are required.

grails-forge's own spockVersion is bumped to 2.4-groovy-4.0 for branch
consistency; its tests use transitive spock, so geantyref flows in
without an explicit declaration.

Assisted-by: claude-code:claude-opus-4-8
Copilot AI review requested due to automatic review settings May 29, 2026 21:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades Spock to 2.4-groovy-4.0 on the 8.0.x branch and aligns related test dependencies, including explicitly adding Spock 2.4’s required geantyref dependency anywhere Spock transitives are stripped.

Changes:

  • Bump Spock and Gradle Spock BOM versions to 2.4-groovy-4.0 and update Selenium to 4.44.0.
  • Add io.leangen.geantyref:geantyref to the BOM/version maps for managed resolution.
  • Add explicit geantyref test dependencies across modules that declare spock-core with transitive = false (or otherwise rely on Spock mocking deps explicitly).

Reviewed changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated no comments.

Show a summary per file
File Description
dependencies.gradle Updates Spock / Gradle-Spock / Selenium versions and adds managed geantyref coordinates/version.
grails-forge/gradle.properties Aligns Forge’s spockVersion with the branch’s Spock upgrade.
grails-async/core/build.gradle Adds geantyref to test runtime deps for Spock 2.4 mocking.
grails-bootstrap/build.gradle Adds geantyref alongside existing explicit Spock mocking dependencies.
grails-codecs-core/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-codecs/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-console/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-controllers/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-converters/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-core/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-data-graphql/core/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-databinding-core/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-databinding/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-datasource/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-domain-class/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-encoder/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-gradle/model/build.gradle Adds geantyref to test dependencies for Spock mocking (build tooling module).
grails-gsp/grails-sitemesh3/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-i18n/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-interceptors/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-logging/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-mimetypes/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-rest-transforms/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-services/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-shell-cli/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-spring/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-test-core/build.gradle Exposes geantyref where spock-core transitives are disabled and adds it for module tests.
grails-test-suite-base/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-test-suite-persistence/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-test-suite-uber/build.gradle Adds geantyref to the aggregate test suite’s explicit mocking deps.
grails-testing-support-core/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-url-mappings/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-validation/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-web-boot/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-web-common/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-web-core/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-web-databinding/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-web-mvc/build.gradle Adds geantyref to test dependencies for Spock mocking.
grails-web-url-mappings/build.gradle Adds geantyref to test dependencies for Spock mocking.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The selenium 4.44.0 bump dragged OpenTelemetry up to 1.62.0, above the
1.55.0 managed by Spring Boot 4.0.6, failing validateDependencyVersions
for grails-geb and the functional test example apps. selenium 4.38.0 is
the version whose OpenTelemetry (1.55.0) matches Boot exactly, so it is
restored (geb-spock is already at its latest 8.0.1, so nothing else to
bump on the Geb/Selenium side).

Also update IOUtilsSpec in grails-gradle-model, which asserts the
expected spock-core jar name, from 2.3-groovy-4.0 to 2.4-groovy-4.0, and
refresh the now-stale Spock version references in AGENTS.md and a
settings.gradle comment.

Assisted-by: claude-code:claude-opus-4-8
Spock 2.4 tightened two behaviors that two existing tests relied on:

- JsonViewTemplateResolverSpec stubbed the final methods getRequest() and
  getResponse() on a GrailsWebRequest mock. Spock 2.3 silently ignored
  final-method stubs; Spock 2.4's byte-buddy mock maker fails fast with
  InvalidSpecException. The stubs were dead (the test passes the request and
  response to resolveView() explicitly), so they are removed.

- TransactionalTransformSpec reflectively invoked the @Rollback-transformed
  Spock feature methods directly, outside Spock's runner. Spock 2.4 throws
  IllegalStateException ("Cannot request current iteration") for closures
  that reference data variables or contain conditions when there is no active
  iteration. The direct call was never faithful to real Spock execution; the
  GroovyShell compilation plus the transformed method-signature assertions
  already cover the #9837 and #9646 regressions, so the direct-invocation
  blocks are removed.

Assisted-by: claude-code:claude-opus-4-8
@testlens-app
Copy link
Copy Markdown

testlens-app Bot commented May 29, 2026

✅ All tests passed ✅

🏷️ Commit: 3e6dabc
▶️ Tests: 21562 executed
⚪️ Checks: 35/35 completed


Learn more about TestLens at testlens.app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants