[#12303] Fix CI-friendly ${revision} not interpolated for non-build POM reads#12322
Open
gnodet wants to merge 1 commit into
Open
[#12303] Fix CI-friendly ${revision} not interpolated for non-build POM reads#12322gnodet wants to merge 1 commit into
gnodet wants to merge 1 commit into
Conversation
c846987 to
882e183
Compare
51f7a30 to
88d031d
Compare
3 tasks
There was a problem hiding this comment.
Pull request overview
Fixes Maven 4 CI-friendly version interpolation (${revision}) for POMs read via the non-build-request path (e.g., dependency/parent POM resolution triggered by plugins such as maven-remote-resources-plugin), where ModelSource.getPath() may be null (notably for ResolvedPathSource) and the interpolation code was previously unreachable.
Changes:
- Update
DefaultModelBuilder.doReadFileModel()to run CI-friendly version interpolation for non-build requests regardless ofmodelSource.getPath()availability. - Add a new core IT (
MavenITgh12303CIFriendlyRevisionRemoteResourcesTest) plus test resources to reproduce and validate the${revision}interpolation when resolving a POM whose parent version contains${revision}. - Add a small local file-based repository fixture (plus settings template) used by the IT.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelBuilder.java |
Makes CI-friendly version interpolation run for non-build model reads even when ModelSource.getPath() is null. |
its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh12303CIFriendlyRevisionRemoteResourcesTest.java |
New IT covering the regression scenario and verifying the fix. |
its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/settings-template.xml |
Test settings pointing Maven at the fixture repo for deterministic resolution. |
its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/pom.xml |
Parent test project using ${revision} CI-friendly version. |
its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/child/pom.xml |
Child module inheriting ${revision} parent version. |
its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/child-b/pom.xml |
Module that triggers dependency resolution involving a parent version containing ${revision}. |
its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/repo/org/apache/maven/its/gh12303/ci-lib/1.0/ci-lib-1.0.pom |
Fixture dependency POM whose parent version uses ${revision}. |
its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/repo/org/apache/maven/its/gh12303/ci-lib-parent/1.0/ci-lib-parent-1.0.pom |
Fixture parent POM defining revision property. |
its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/resource-bundle/src/main/resources/NOTICE.txt |
Minimal resource bundle content used by the remote-resources plugin. |
its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/resource-bundle/src/main/resources/META-INF/maven/remote-resources.xml |
Remote-resources bundle descriptor. |
its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/resource-bundle/pom.xml |
Resource bundle project POM (test fixture). |
its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/repo/org/apache/maven/its/gh12303/resource-bundle/1.0/resource-bundle-1.0.pom |
Pre-baked POM in the fixture repo for the resource bundle artifact. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1714
to
+1717
| } catch (ModelBuilderException e) { | ||
| logger.debug("Could not read root model properties for CI-friendly" | ||
| + " version interpolation: " + e.getMessage()); | ||
| } |
…dency POMs
In DefaultModelBuilder.doReadFileModel(), the CI-friendly version
interpolation for non-build requests (dependency/parent POM reads)
was guarded by `else if (modelSource.getPath() != null)`.
Since ResolvedPathSource.getPath() always returns null for
repository-resolved POMs, the ${revision} replacement never executed.
Changed to unconditional else so getEnhancedProperties() and
replaceCiFriendlyVersion() always run for non-build requests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the
${revision}CI-friendly version placeholder not being interpolated when Maven reads dependency or parent POMs outside of a build request (e.g. when themaven-remote-resources-pluginresolves the project's own POM).DefaultModelBuilder.doReadFileModel(), the CI-friendly version interpolation for non-build requests was guarded byelse if (modelSource.getPath() != null). SinceResolvedPathSource.getPath()always returnsnull, thereplaceCiFriendlyVersion()call was dead code.elseblock sogetEnhancedProperties()andreplaceCiFriendlyVersion()always run for non-build requests.${revision}in its version.Verified against the original use case (bigtop-manager project from #12303): without the fix,
process-resourcesfails withInvalid Version Range Request: ...pom:${revision}; with the fix, the version resolves correctly to1.2.0-SNAPSHOT.Fixes #12303
Test plan
MavenITgh12303CIFriendlyRevisionRemoteResourcesTestpassesClaude Code on behalf of Guillaume Nodet