Skip to content

[#12303] Fix CI-friendly ${revision} not interpolated for non-build POM reads#12322

Open
gnodet wants to merge 1 commit into
apache:maven-4.0.xfrom
gnodet:fix-12303
Open

[#12303] Fix CI-friendly ${revision} not interpolated for non-build POM reads#12322
gnodet wants to merge 1 commit into
apache:maven-4.0.xfrom
gnodet:fix-12303

Conversation

@gnodet

@gnodet gnodet commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

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 the maven-remote-resources-plugin resolves the project's own POM).

  • In DefaultModelBuilder.doReadFileModel(), the CI-friendly version interpolation for non-build requests was guarded by else if (modelSource.getPath() != null). Since ResolvedPathSource.getPath() always returns null, the replaceCiFriendlyVersion() call was dead code.
  • Changed to an unconditional else block so getEnhancedProperties() and replaceCiFriendlyVersion() always run for non-build requests.
  • Added IT that exercises the fix with a dependency whose parent POM uses ${revision} in its version.

Verified against the original use case (bigtop-manager project from #12303): without the fix, process-resources fails with Invalid Version Range Request: ...pom:${revision}; with the fix, the version resolves correctly to 1.2.0-SNAPSHOT.

Fixes #12303

Test plan

Claude Code on behalf of Guillaume Nodet

@gnodet gnodet force-pushed the fix-12303 branch 2 times, most recently from c846987 to 882e183 Compare June 19, 2026 09:18
@gnodet gnodet marked this pull request as ready for review June 19, 2026 09:57
@gnodet gnodet changed the title [#12303] Fix CI-friendly ${revision} not interpolated for dependency POMs [#12303] Fix CI-friendly ${revision} not interpolated for non-build POM reads Jun 19, 2026
@gnodet gnodet requested review from cstamas and hboutemy June 19, 2026 09:59
@gnodet gnodet force-pushed the fix-12303 branch 2 times, most recently from 51f7a30 to 88d031d Compare June 19, 2026 11:32
@gnodet gnodet added this to the 4.0.0-rc-6 milestone Jun 22, 2026
@gnodet gnodet added mvn40 bug Something isn't working labels Jun 22, 2026
@gnodet gnodet requested a review from Copilot June 24, 2026 21:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 of modelSource.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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mvn40

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants