Repository navigation
Fix project validation level handling during parent resolution - #13601
abdulhannansyed548-cmd wants to merge 5 commits into
Conversation
|
gnodet-bot
left a comment
There was a problem hiding this comment.
The approach is on the right track but there are blocking issues before this can merge.
Critical: request.getValidationLevel() from the compat layer returns Maven 3 numeric constants (e.g. VALIDATION_LEVEL_STRICT = 30), but the SPI ModelValidator uses a different scale where VALIDATION_LEVEL_STRICT = 42. Forwarding the raw int silently downgrades every build-mode validation call from 4.2-strict to Maven-3.0-level. A translation step is needed in DefaultProjectBuilder before the value crosses the API boundary.
Also blocking: validateFileModel was not updated alongside validateRawModel and validateEffectiveModel, leaving the three-phase validation inconsistent.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — 5 of the 7 issues have been addressed. The two outdated threads (indentation, import ordering) no longer apply. One critical issue with the domain translation remains.
Addressed:
- ✅
validateFileModel— all threevalidate*calls now route throughgetValidationLevel() - ✅
@Nullable+ Javadoc — the interface method is now documented - ✅ Builder method — now accepts
Integer, notint - ✅ Test coverage — the
hasRelativePathWarningassertion indirectly verifies that the compat→SPI translation actually fires (the warning triggers at>= VALIDATION_LEVEL_MAVEN_4_0 = 40, so only a correctly-translated 42 triggers it, not the raw compat 30)
Still open:
- ⛔ Domain mismatch fix is broken — see inline comment
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
Hi @abdulhannansyed548-cmd, I was looking into the review feedback on this PR and worked out a fix on top of your two commits that makes your regression test and the existing project tests pass. I don’t want to open a competing PR on an issue you’ve claimed, so here it is for you to use or adapt: https://github.com/Shreekar-cloud/maven/tree/fix-13395-parent-resolution (single commit 6773436). With a baseline run without the production changes, testLocalParentResolutionWithValidationLevels fails with “Non-resolvable parent POM”. The cause: for a non-reactor build(File), DefaultProjectBuilder only picks BUILD_EFFECTIVE for processPlugins && STRICT, and DefaultModelBuilder only looks for local parents for build requests (findLocalParent is gated on isBuildRequest()). The change: (1) pomFile != null now means a project build (repository-resolved artifacts have pomFile == null, so those are unchanged); (2) the validation level is forwarded only for build requests, leaving compat STRICT (30) to the default SPI STRICT (42) and passing lower levels, which have the same values in both APIs, unchanged, so consumer requests keep their old defaults; (3) AbstractMavenProjectTestCase sets a scope manager, since these tests now go through strict effective validation. Behavior changes worth review: build(File) with default STRICT and processPlugins=false is now validated strictly (as in Maven 3), and workspace project POMs resolved as dependencies are now built as projects. Locally I ran ProjectBuilderTest, the org.apache.maven.project tests and the maven-impl model/cache tests (259 tests in maven-core, 0 failures). I haven’t run the full suite or spotless, so CI is the real check. Happy to open a PR myself or send a patch if you’d prefer that. Just let me know. |
|
@Shreekar-cloud Thanks, Shreekar! I went ahead and applied your proposed fix to my branch and pushed it to PR #13601. I've included the regression test as well. I'm still facing a local test-compilation issue, so I haven't been able to verify the test run yet. Really appreciate you sharing the approach! |
gnodet-bot
left a comment
There was a problem hiding this comment.
The validation-level forwarding logic is sound and the domain mismatch fix is correct. One behavioral regression to address.
High — pomFile != null unconditionally yields BUILD_EFFECTIVE
Before this PR, BUILD_EFFECTIVE required pomFile != null && request.isProcessPlugins() && request.getValidationLevel() == ModelBuildingRequest.VALIDATION_LEVEL_STRICT. The validation-level condition was correctly dropped since it's now forwarded separately. However, dropping isProcessPlugins() too is a behavioral change: embedders calling build(File, request) with processPlugins=false previously got CONSUMER_PARENT/CONSUMER_DEPENDENCY request types; they now get BUILD_EFFECTIVE, which changes XML parsing strictness, parent resolution, and repository merging.
Metadata: category=bug, milestone=4.1.0
This review was generated by an AI agent, Hermès on behalf of @gnodet.
| ModelBuilderRequest.RequestType type = reactorMember || isStandalone || pomFile != null | ||
| ? ModelBuilderRequest.RequestType.BUILD_EFFECTIVE | ||
| : (parent | ||
| ? ModelBuilderRequest.RequestType.CONSUMER_PARENT |
There was a problem hiding this comment.
pomFile != null is too broad. The isProcessPlugins() guard was removed along with the validation-level condition, but only the latter was made redundant by this PR.
Embedders calling build(File, request) with processPlugins=false now get BUILD_EFFECTIVE instead of CONSUMER_PARENT/CONSUMER_DEPENDENCY. This changes XML parsing strictness, parent resolution, and repository merging — beyond the scope of the validation-level fix.
| ModelBuilderRequest.RequestType type = reactorMember || isStandalone || pomFile != null | |
| ? ModelBuilderRequest.RequestType.BUILD_EFFECTIVE | |
| : (parent | |
| ? ModelBuilderRequest.RequestType.CONSUMER_PARENT | |
| ModelBuilderRequest.RequestType type = reactorMember || isStandalone || (pomFile != null && request.isProcessPlugins()) |
|
|
||
| @Nonnull | ||
| RequestType getRequestType(); | ||
| /** |
There was a problem hiding this comment.
💡 Missing blank line between getRequestType() and the Javadoc for getValidationLevel(). Every other method in this interface has a blank separator before its Javadoc block.
| /** | |
| RequestType getRequestType(); | |
| /** |
gnodet-bot
left a comment
There was a problem hiding this comment.
Two issues found in this PR.
1. Minor — missing blank line before Javadoc in ModelBuilderRequest.java
The new getValidationLevel() Javadoc starts immediately after getRequestType(); with no blank line separating them, breaking the consistent formatting style of the interface (every other method declaration has a blank line before its Javadoc).
2. Real bug — test assertion incorrect for (STRICT, processPlugins=false)
When processPlugins=false, DefaultProjectBuilder computes type = CONSUMER_DEPENDENCY (because pomFile != null && request.isProcessPlugins() is false). The validationLevel override is then null (the condition type == BUILD_EFFECTIVE && request.getValidationLevel() != STRICT is false). Inside DefaultModelBuilder.getValidationLevel(), the effective level becomes MINIMAL(0) for a non-build request. With level 0, no relativePath warning is emitted (requires ≥ 40 / MAVEN_4_0). But the assertion assertEquals(validationLevel == VALIDATION_LEVEL_STRICT, hasRelativePathWarning) evaluates to assertEquals(true, false) and fails. Please fix the assertion to account for processPlugins=false producing CONSUMER_DEPENDENCY type, or adjust the test matrix to only include combinations where a warning is actually expected.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
|
||
| @Nonnull | ||
| RequestType getRequestType(); | ||
| /** |
There was a problem hiding this comment.
🔧 Style: Missing blank line before the Javadoc. Every other method in this interface has a blank line between the previous method declaration and its Javadoc. Please add one here:
| /** | |
| /** |
| assertEquals( | ||
| validationLevel == ModelBuildingRequest.VALIDATION_LEVEL_STRICT, | ||
| hasRelativePathWarning, |
There was a problem hiding this comment.
(STRICT=30, processPlugins=false).
When processPlugins=false, DefaultProjectBuilder sets type = CONSUMER_DEPENDENCY (the pomFile != null && request.isProcessPlugins() branch is false). The validationLevel override is therefore null, and DefaultModelBuilder.getValidationLevel() falls back to MINIMAL(0) for a non-build request. No relativePath warning is emitted at level 0 (the threshold is MAVEN_4_0 = 40), so hasRelativePathWarning is false — but validationLevel == VALIDATION_LEVEL_STRICT is true (30 == 30), causing the assertion to fail.
The test needs to account for the fact that processPlugins=false suppresses validation regardless of the requested level. Consider adjusting the expected value based on both validationLevel and processPlugins, or narrow the test matrix to only the combinations where a warning is actually produced.
|
Thanks for applying that, @abdulhannansyed548-cmd. I checked out the current head of this PR (aeb6dc1) and ran the regression test, and I found two small things that would likely stop CI from going green:
java Running mvn spotless:apply (or any normal build) will apply it. The bot’s earlier note about the missing blank line before the getValidationLevel() Javadoc in ModelBuilderRequest.java is still open too. Caveat: I only ran that one test on your branch, not the full suite, so CI is still the real check. |
gnodet
left a comment
There was a problem hiding this comment.
Thanks for the fix — the root cause analysis is correct: the RequestType selection in DefaultProjectBuilder should not depend on validationLevel, and decoupling them is the right move.
However, adding Integer getValidationLevel() to the public ModelBuilderRequest API breaks the encapsulation that RequestType was designed to provide. The whole point of the API was for callers to express their intent, and have the implementation decide the validation level internally. A nullable Integer leaks implementation details (numeric validation level constants) into the public contract, and the compat layer comment itself acknowledges the mismatch ("Maven 3 STRICT (30) is not the SPI STRICT (42)").
A cleaner alternative would be to add a new RequestType enum value — something like LOAD_PROJECT — that captures the IDE use case: "I'm loading a project from a local POM file and need profile activation and user properties, but I don't need strict build-time validation." The DefaultModelBuilder would then map this request type to VALIDATION_LEVEL_MINIMAL internally, just like it already does for CONSUMER_PARENT / CONSUMER_DEPENDENCY. No validation level on the API surface.
This keeps the design principle intact: RequestType captures caller intent, the implementation decides validation strictness.
The DefaultProjectBuilder compat layer would then map:
processPlugins=true && validationLevel==STRICT→BUILD_EFFECTIVEprocessPlugins=true && validationLevel!=STRICT→LOAD_PROJECT(or whatever name fits best)- parent resolution →
CONSUMER_PARENT - dependency resolution →
CONSUMER_DEPENDENCY
Fully automatic review from Claude Code
|
@abdulhannansyed548-cmd, following gnodet's review I'm preparing the LOAD_PROJECT variant on top of your branch and will run the tests on my side (Windows, JDK 25). I'll share a tested branch in a day or two. If you'd rather do it yourself or are already on it, just tell me and I'll send my notes instead. |
|
@Shreekar-cloud Thanks, Shreekar! I'm already working on the LOAD_PROJECT changes following gnodet's review. Since you can run the tests on Windows with JDK 25, I'd appreciate it if you could share your tested branch and notes once they're ready. I'll avoid making further changes until I can compare the implementations. Thanks for helping with this! |
|
Hi @abdulhannansyed548-cmd, thanks for building on this and for waiting. I applied the LOAD_PROJECT approach on top of your head (aeb6dc1) and pushed it here: https://github.com/Shreekar-cloud/maven/tree/fix-13395-load-project What it does:
Testing: ProjectBuilderTest#testLocalParentResolutionWithValidationLevels passes, and the maven-core, model and cache tests pass (259 run, 0 failures, 1 skipped). How would you like to handle it? You can take these changes into your PR, or I can open a separate PR that credits you as co-author so the maintainers can pick one. Either works for me. I'll wait for your answer before opening anything. Notes for review:
|
|
@Shreekar-cloud Thanks a lot for taking the time to build on my work and validate the Please go ahead and open the separate PR, crediting me as co-author as you suggested. I’ll review the changes carefully and coordinate with the maintainers so we can avoid duplicate work and make the review process as smooth as possible. Thanks again for your help and for making this a great learning experience for me! |
|
@abdulhannansyed548-cmd Thanks, Abdul! I've opened #13669 with the LOAD_PROJECT change, with you credited as co-author. Whichever PR the maintainers prefer is fine with me. |
|
Superseded by #13669 |
Fixes #13395.
Summary
ModelBuilderRequest.Testing
Production compilation succeeded for the relevant Maven Core modules in local checks.
Maven Core test compilation encountered local model-class and classpath errors, so the new regression test has not been confirmed passing locally.
Please verify the regression test and full build in CI.
I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0).