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
The following commit(s) were added to refs/heads/maven-4.0.x by this push:
new 30411c5b49 [Backport maven-4.0.x] Fix reactor parent resolution from
active profile repositories (#13876)
30411c5b49 is described below
commit 30411c5b4914755f8ac7231c312bcdadfd6d4ba1
Author: Guillaume Nodet <[email protected]>
AuthorDate: Sat Nov 7 08:06:40 2026 +0100
[Backport maven-4.0.x] Fix reactor parent resolution from active profile
repositories (#13876)
---
.../maven/impl/model/DefaultModelBuilder.java | 12 +++-
...h13809ParentResolutionFromProfileReposTest.java | 76 ++++++++++++++++++++++
.../child/pom.xml | 29 +++++++++
.../pom-template.xml | 46 +++++++++++++
.../repo/.gitattributes | 1 +
.../parent/1.0-SNAPSHOT/parent-1.0-SNAPSHOT.pom | 26 ++++++++
.../1.0-SNAPSHOT/parent-1.0-SNAPSHOT.pom.sha1 | 1 +
7 files changed, 190 insertions(+), 1 deletion(-)
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 0ce0c25b4d..34279e2dff 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
@@ -2254,7 +2254,17 @@ private ParentModelWithProfiles doReadAsParentModel(
DefaultProfileActivationContext childProfileActivationContext,
Set<String> parentChain)
throws ModelBuilderException {
Model raw = readRawModel();
- Model parentData = readParent(raw, raw.getParent(),
childProfileActivationContext, parentChain);
+ Model parentResolutionModel = raw;
+ if (raw.getProfiles().stream().anyMatch(p ->
!p.getRepositories().isEmpty())) {
+ // Parent lookup needs profile repositories before assembling
the ancestry.
+ // Keep final profile injection after inheritance, using the
child's context.
+ DefaultProfileActivationContext activation =
childProfileActivationContext.start(raw.getProperties());
+ List<Profile> profiles = getActiveProfiles(raw.getProfiles(),
activation);
+ replayRecordIntoContext(activation.stop(),
childProfileActivationContext, false);
+ parentResolutionModel = profileInjector.injectProfiles(raw,
profiles, request, this);
+ }
+ Model parentData =
+ readParent(parentResolutionModel, raw.getParent(),
childProfileActivationContext, parentChain);
Model parent = new DefaultInheritanceAssembler(new
DefaultInheritanceAssembler.InheritanceModelMerger() {
@Override
protected void mergeModel_Modules(
diff --git
a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh13809ParentResolutionFromProfileReposTest.java
b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh13809ParentResolutionFromProfileReposTest.java
new file mode 100644
index 0000000000..b4f3654219
--- /dev/null
+++
b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh13809ParentResolutionFromProfileReposTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+class MavenITgh13809ParentResolutionFromProfileReposTest extends
AbstractMavenIntegrationTestCase {
+
+ MavenITgh13809ParentResolutionFromProfileReposTest() {
+ super("[4.0.0,)");
+ }
+
+ @Test
+ void testExplicitProfileInReactor() throws Exception {
+ Verifier verifier = verifier("explicit");
+ verifier.addCliArgument("-Pparent-repository");
+ verifier.execute();
+ verifier.verifyErrorFreeLog();
+ }
+
+ @Test
+ void testPropertyActivatedProfileInReactor() throws Exception {
+ Verifier verifier = verifier("property");
+ verifier.addCliArgument("-Dparent.repository=true");
+ verifier.execute();
+ verifier.verifyErrorFreeLog();
+ }
+
+ @Test
+ void testNonRecursiveBuild() throws Exception {
+ Verifier verifier = verifier("nonrecursive");
+ verifier.addCliArgument("-Pparent-repository");
+ verifier.addCliArgument("-N");
+ verifier.execute();
+ verifier.verifyErrorFreeLog();
+ }
+
+ @Test
+ void testInactiveProfileDoesNotProvideRepository() throws Exception {
+ Verifier verifier = verifier("inactive");
+ assertThrows(VerificationException.class, verifier::execute);
+ verifier.verifyTextInLog("Non-resolvable parent POM");
+ }
+
+ private Verifier verifier(String name) throws Exception {
+ File testDir = extractResources("/gh-13809-parent-profile-repository");
+ Verifier verifier = newVerifier(testDir.getPath());
+ verifier.setAutoclean(false);
+ verifier.deleteDirectory("local-repo-" + name);
+ verifier.setLogFileName("log-" + name + ".txt");
+ verifier.filterFile("pom-template.xml", "pom.xml");
+ verifier.addCliArgument("-Dmaven.repo.local=" + new File(testDir,
"local-repo-" + name).getPath());
+ verifier.addCliArgument("validate");
+ return verifier;
+ }
+}
diff --git
a/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/child/pom.xml
b/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/child/pom.xml
new file mode 100644
index 0000000000..e12cce8d85
--- /dev/null
+++
b/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/child/pom.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.maven.its.gh13809</groupId>
+ <artifactId>root</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>child</artifactId>
+ <packaging>pom</packaging>
+</project>
diff --git
a/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/pom-template.xml
b/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/pom-template.xml
new file mode 100644
index 0000000000..c630f4d9c0
--- /dev/null
+++
b/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/pom-template.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.maven.its.gh13809</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath />
+ </parent>
+ <artifactId>root</artifactId>
+ <packaging>pom</packaging>
+ <modules><module>child</module></modules>
+ <profiles>
+ <profile>
+ <id>parent-repository</id>
+
<activation><property><name>parent.repository</name></property></activation>
+
<properties><parent.repository.url>@baseurl@/repo</parent.repository.url></properties>
+ <repositories>
+ <repository>
+ <id>parent-repository</id>
+ <url>${parent.repository.url}</url>
+ <releases><enabled>false</enabled></releases>
+ <snapshots><enabled>true</enabled></snapshots>
+ </repository>
+ </repositories>
+ </profile>
+ </profiles>
+</project>
diff --git
a/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/repo/.gitattributes
b/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/repo/.gitattributes
new file mode 100644
index 0000000000..eb4d40ce69
--- /dev/null
+++
b/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/repo/.gitattributes
@@ -0,0 +1 @@
+*.pom -text
diff --git
a/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/repo/org/apache/maven/its/gh13809/parent/1.0-SNAPSHOT/parent-1.0-SNAPSHOT.pom
b/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/repo/org/apache/maven/its/gh13809/parent/1.0-SNAPSHOT/parent-1.0-SNAPSHOT.pom
new file mode 100644
index 0000000000..7b5807e33c
--- /dev/null
+++
b/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/repo/org/apache/maven/its/gh13809/parent/1.0-SNAPSHOT/parent-1.0-SNAPSHOT.pom
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.its.gh13809</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+</project>
diff --git
a/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/repo/org/apache/maven/its/gh13809/parent/1.0-SNAPSHOT/parent-1.0-SNAPSHOT.pom.sha1
b/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/repo/org/apache/maven/its/gh13809/parent/1.0-SNAPSHOT/parent-1.0-SNAPSHOT.pom.sha1
new file mode 100644
index 0000000000..8758343b83
--- /dev/null
+++
b/its/core-it-suite/src/test/resources/gh-13809-parent-profile-repository/repo/org/apache/maven/its/gh13809/parent/1.0-SNAPSHOT/parent-1.0-SNAPSHOT.pom.sha1
@@ -0,0 +1 @@
+f83027b3bbf28e46ee04ebb8aa0b4de4efd8e839