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/27 23:23:05 UTC
(maven) 01/02: [#12303] Fix CI-friendly ${revision} not interpolated for dependency POMs
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch maven-4.0.x
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 273174652a7a3fc33f0b9cd4df8462f45e888577
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Jun 19 11:08:57 2026 +0200
[#12303] Fix CI-friendly ${revision} not interpolated for dependency 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.
---
.../maven/impl/model/DefaultModelBuilder.java | 26 +++++++++
...12303CIFriendlyRevisionRemoteResourcesTest.java | 65 +++++++++++++++++++++
.../child-b/pom.xml | 27 +++++++++
.../child/pom.xml | 13 +++++
.../pom.xml | 41 +++++++++++++
.../ci-lib-parent/1.0/ci-lib-parent-1.0.pom | 14 +++++
.../maven/its/gh12303/ci-lib/1.0/ci-lib-1.0.pom | 14 +++++
.../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 +++++++++++
13 files changed, 258 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 a877ba7cc9..f9a56304a9 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
@@ -1692,6 +1692,32 @@ 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);
+ }
+ }
}
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..b241caec6a
--- /dev/null
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh12303CIFriendlyRevisionRemoteResourcesTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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 resolving a dependency whose parent POM uses {@code ${revision}} in its
+ * version. This exercises the non-build-request code path in
+ * {@code DefaultModelBuilder.doReadFileModel()}.
+ *
+ * @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");
+
+ // Pre-install the resource-bundle into the local repo so the
+ // maven-remote-resources-plugin can find it.
+ File repoDir = new File(testDir, "repo");
+ File rbDir = new File(repoDir, "org/apache/maven/its/gh12303/resource-bundle/1.0");
+ verifier.addCliArguments(
+ "install:install-file",
+ "-Dfile=" + new File(rbDir, "resource-bundle-1.0.jar").getAbsolutePath(),
+ "-DpomFile=" + new File(rbDir, "resource-bundle-1.0.pom").getAbsolutePath());
+ verifier.execute();
+ verifier.verifyErrorFreeLog();
+
+ verifier = newVerifier(testDir.getAbsolutePath());
+ verifier.filterFile("settings-template.xml", "settings.xml");
+ verifier.addCliArgument("--settings");
+ verifier.addCliArgument("settings.xml");
+ verifier.addCliArgument("compile");
+ 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..9ef6895490
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-12303-ci-friendly-revision-remote-resources/child-b/pom.xml
@@ -0,0 +1,27 @@
+<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>
+ <dependency>
+ <groupId>org.apache.maven.its.gh12303</groupId>
+ <artifactId>ci-lib</artifactId>
+ <version>1.0</version>
+ <type>pom</type>
+ </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..c032a1a734
--- /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</revision>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <version>3.0.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/ci-lib-parent/1.0/ci-lib-parent-1.0.pom b/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
new file mode 100644
index 0000000000..5977b1dc1b
--- /dev/null
+++ b/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
@@ -0,0 +1,14 @@
+<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>ci-lib-parent</artifactId>
+ <version>1.0</version>
+ <packaging>pom</packaging>
+
+ <properties>
+ <revision>1.0</revision>
+ </properties>
+</project>
diff --git a/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 b/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
new file mode 100644
index 0000000000..468a779559
--- /dev/null
+++ b/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
@@ -0,0 +1,14 @@
+<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>ci-lib-parent</artifactId>
+ <version>${revision}</version>
+ </parent>
+
+ <artifactId>ci-lib</artifactId>
+ <packaging>pom</packaging>
+</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>