You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/06/23 13:04:45 UTC
(maven) branch port/gh-12303-fix-master created (now dd7ef4710f)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a change to branch port/gh-12303-fix-master
in repository https://gitbox.apache.org/repos/asf/maven.git
at dd7ef4710f [#12303] Fix CI-friendly ${revision} not interpolated for non-build POM reads
This branch includes the following new commits:
new dd7ef4710f [#12303] Fix CI-friendly ${revision} not interpolated for non-build POM reads
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(maven) 01/01: [#12303] Fix CI-friendly ${revision} not interpolated for non-build POM reads
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch port/gh-12303-fix-master
in repository https://gitbox.apache.org/repos/asf/maven.git
commit dd7ef4710f446ab38eff749c0d3c5acbcf47ad83
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue Jun 23 15:04:33 2026 +0200
[#12303] Fix CI-friendly ${revision} not interpolated for non-build POM reads
Port of #12322 to master.
In doReadFileModel(), the CI-friendly version interpolation was only
performed inside the isBuildRequest() block. When plugins like
maven-remote-resources-plugin resolve the project's own POM through
the non-build code path, ${revision} was left uninterpolated, causing
"Invalid Version Range Request" errors.
Add an else branch that performs CI-friendly version interpolation
for non-build requests as well.
Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
.../maven/impl/model/DefaultModelBuilder.java | 24 ++++++++++
...12303CIFriendlyRevisionRemoteResourcesTest.java | 51 +++++++++++++++++++++
.../child-b/pom.xml | 21 +++++++++
.../child/pom.xml | 13 ++++++
.../pom.xml | 41 +++++++++++++++++
.../resource-bundle/1.0/resource-bundle-1.0.jar | Bin 0 -> 833 bytes
.../resource-bundle/1.0/resource-bundle-1.0.pom | 9 ++++
.../resource-bundle/pom.xml | 9 ++++
.../resources/META-INF/maven/remote-resources.xml | 6 +++
.../resource-bundle/src/main/resources/NOTICE.txt | 1 +
.../settings-template.xml | 33 +++++++++++++
11 files changed, 208 insertions(+)
diff --git a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelBuilder.java b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelBuilder.java
index 28a917c948..f89f9d4f92 100644
--- a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelBuilder.java
+++ b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelBuilder.java
@@ -1741,6 +1741,30 @@ Model doReadFileModel(Set<Path> activeModelReads) throws ModelBuilderException {
model = model.withProperties(newProps);
}
model = model.withProfiles(merge(model.getProfiles(), userProps));
+ } else {
+ if (modelSource.getPath() != null) {
+ model = model.withPomFile(modelSource.getPath());
+ }
+ if (rootDirectory != null) {
+ try {
+ Map<String, String> properties =
+ getEnhancedProperties(model, rootDirectory, activeModelReads);
+ model = model.with()
+ .version(replaceCiFriendlyVersion(properties, model.getVersion()))
+ .parent(
+ model.getParent() != null
+ ? model.getParent()
+ .withVersion(replaceCiFriendlyVersion(
+ properties,
+ model.getParent()
+ .getVersion()))
+ : null)
+ .build();
+ } catch (ModelBuilderException e) {
+ logger.debug("Could not read root model properties for CI-friendly"
+ + " version interpolation: " + e.getMessage());
+ }
+ }
}
for (var transformer : transformers) {
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh12303CIFriendlyRevisionRemoteResourcesTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh12303CIFriendlyRevisionRemoteResourcesTest.java
new file mode 100644
index 0000000000..b1ab171af6
--- /dev/null
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh12303CIFriendlyRevisionRemoteResourcesTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.it;
+
+import java.io.File;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Verify that CI-friendly {@code ${revision}} versions are properly interpolated
+ * when the {@code maven-remote-resources-plugin} resolves the project's own artifact
+ * through the legacy resolver path.
+ *
+ * @see <a href="https://github.com/apache/maven/issues/12303">gh-12303</a>
+ */
+class MavenITgh12303CIFriendlyRevisionRemoteResourcesTest extends AbstractMavenIntegrationTestCase {
+
+ MavenITgh12303CIFriendlyRevisionRemoteResourcesTest() {
+ super("[4.0.0-rc-3,)");
+ }
+
+ @Test
+ void testCiFriendlyRevisionWithRemoteResources() throws Exception {
+ File testDir = extractResources("/gh-12303-ci-friendly-revision-remote-resources");
+
+ Verifier verifier = newVerifier(testDir.getAbsolutePath());
+ verifier.deleteArtifacts("org.apache.maven.its.gh12303");
+ verifier.filterFile("settings-template.xml", "settings.xml");
+ verifier.addCliArgument("--settings");
+ verifier.addCliArgument("settings.xml");
+ verifier.addCliArgument("process-resources");
+ verifier.execute();
+ verifier.verifyErrorFreeLog();
+ }
+}
diff --git a/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/child-b/pom.xml b/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/child-b/pom.xml
new file mode 100644
index 0000000000..bcf2f609a2
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/child-b/pom.xml
@@ -0,0 +1,21 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.its.gh12303</groupId>
+ <artifactId>parent</artifactId>
+ <version>${revision}</version>
+ </parent>
+
+ <artifactId>child-b</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.gh12303</groupId>
+ <artifactId>child</artifactId>
+ <version>${revision}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/child/pom.xml b/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/child/pom.xml
new file mode 100644
index 0000000000..892c520eb6
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/child/pom.xml
@@ -0,0 +1,13 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.its.gh12303</groupId>
+ <artifactId>parent</artifactId>
+ <version>${revision}</version>
+ </parent>
+
+ <artifactId>child</artifactId>
+</project>
diff --git a/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/pom.xml b/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/pom.xml
new file mode 100644
index 0000000000..8ac1c1b6fa
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/pom.xml
@@ -0,0 +1,41 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.gh12303</groupId>
+ <artifactId>parent</artifactId>
+ <version>${revision}</version>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>child</module>
+ <module>child-b</module>
+ </modules>
+
+ <properties>
+ <revision>1.0.0-SNAPSHOT</revision>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <version>1.7.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ <configuration>
+ <resourceBundles>
+ <resourceBundle>org.apache.maven.its.gh12303:resource-bundle:1.0</resourceBundle>
+ </resourceBundles>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/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.jar b/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.jar
new file mode 100644
index 0000000000..6f1b5c0898
Binary files /dev/null and b/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.jar differ
diff --git a/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 b/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
new file mode 100644
index 0000000000..c3199b2598
--- /dev/null
+++ b/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
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.gh12303</groupId>
+ <artifactId>resource-bundle</artifactId>
+ <version>1.0</version>
+</project>
diff --git a/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/resource-bundle/pom.xml b/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/resource-bundle/pom.xml
new file mode 100644
index 0000000000..c3199b2598
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/resource-bundle/pom.xml
@@ -0,0 +1,9 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.gh12303</groupId>
+ <artifactId>resource-bundle</artifactId>
+ <version>1.0</version>
+</project>
diff --git a/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 b/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
new file mode 100644
index 0000000000..45c118bebd
--- /dev/null
+++ b/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
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<remoteResourcesBundle>
+ <remoteResources>
+ <remoteResource>NOTICE.txt</remoteResource>
+ </remoteResources>
+</remoteResourcesBundle>
diff --git a/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/resource-bundle/src/main/resources/NOTICE.txt b/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/resource-bundle/src/main/resources/NOTICE.txt
new file mode 100644
index 0000000000..a2e56e1ac4
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/resource-bundle/src/main/resources/NOTICE.txt
@@ -0,0 +1 @@
+Test notice file for IT gh-12303.
diff --git a/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/settings-template.xml b/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/settings-template.xml
new file mode 100644
index 0000000000..7e5ab0f680
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/settings-template.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<settings>
+ <profiles>
+ <profile>
+ <id>it-repo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>local-repo</id>
+ <url>@baseurl@/repo</url>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>ignore</checksumPolicy>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>central-plugins</id>
+ <url>https://repo.maven.apache.org/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+</settings>