Skip to content

Declare Hibernate Validator and Jakarta EL as test-only dependencies of fixture-monkey-jakarta-validation - #1351

Open
onacit wants to merge 1 commit into
naver:mainfrom
onacit:jakarta-validation-dependency-scopes
Open

onacit wants to merge 1 commit into
naver:mainfrom
onacit:jakarta-validation-dependency-scopes

Conversation

@onacit

@onacit onacit commented Sep 30, 2026

Copy link
Copy Markdown

Summary

Closes #1350.

fixture-monkey-jakarta-validation no longer publishes a Bean Validation implementation with compile scope. hibernate-validator and jakarta.el become test-only dependencies, and jakarta.validation-api becomes compileOnly.

(Optional): Description

  • fixture-monkey-jakarta-validation/build.gradle.kts
    • hibernate-validator, jakarta.el: api → testImplementation
    • jakarta.validation-api: api → compileOnly + testImplementation
  • fixture-monkey-tests/doc-examples/java-examples and fixture-monkey-tests/kotlin-tests use jakarta.validation.constraints.* directly, but only received the API transitively. They now declare jakarta.validation-api, hibernate-validator and jakarta.el as testImplementation.

Published POM of fixture-monkey-jakarta-validation (generatePomFileForFixtureMonkeyPublication):

Dependency Before After
org.hibernate.validator:hibernate-validator:7.0.5.Final compile removed
jakarta.validation:jakarta.validation-api:3.0.2 compile removed
org.glassfish:jakarta.el:4.0.2 compile removed
fixture-monkey-api, jsr305 compile compile (unchanged)
findbugs-annotations, jspecify runtime runtime (unchanged)

This is a behaviour change for users: anyone relying on the bundled Hibernate Validator, including fixture-monkey-starter users, will need to add a provider. The trade-offs are listed in #1350. I'm happy to switch to a different approach (for example, keeping the provider at runtime scope) if you prefer.

How Has This Been Tested?

Full clean build on d6e285af4: every build/ directory deleted, then ./gradlew --continue --no-build-cache build (Gradle 8.5 on JDK 17, Java 8 toolchain). I deleted the directories by hand because fixture-monkey-tests/* disables its clean task.

Run Result
Baseline (unchanged) BUILD SUCCESSFUL, 265/265 tasks executed
Module change only BUILD FAILED: java-examples:compileTestJava, kotlin-tests:compileTestKotlin (package jakarta.validation.constraints does not exist)
This PR BUILD SUCCESSFUL, 265/265 tasks executed; per-project test counts identical to the baseline, 0 failures

The resolved validation dependencies in the testRuntimeClasspath of java-examples and kotlin-tests are identical before and after this change.

Not tested: running with an external provider (for example Hibernate Validator 8 via Spring Boot), or publishing to a repository.

Is the Document updated?

Yes, the "already provided as part of the dependency" sentence in plugins/jakarta-validation-plugin/features.mdx (en, ko) now says that a provider must be added. Versioned docs are unchanged. If you'd like, I can also add a note to get-started/adding-bean-validation.md.

🤖 Generated with Claude Code

…of fixture-monkey-jakarta-validation

The module only uses the jakarta.validation API; the provider is looked up
at runtime. Stop publishing hibernate-validator, jakarta.el and
jakarta.validation-api with compile scope, and let the test projects that
use the constraint annotations declare them directly.

Closes naver#1350

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Sep 30, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Declare Hibernate Validator and Jakarta EL as test-only dependencies of fixture-monkey-jakarta-validation

2 participants