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 2025/10/30 18:46:11 UTC
(maven) branch maven-4.0.x updated: [maven-4.0.x] Fix -itr option not honored (#11359) (#11361)
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 bf798f4453 [maven-4.0.x] Fix -itr option not honored (#11359) (#11361)
bf798f4453 is described below
commit bf798f4453607f0b14c70e251674055d40e5d3d3
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Thu Oct 30 19:46:06 2025 +0100
[maven-4.0.x] Fix -itr option not honored (#11359) (#11361)
Fixes #2576
(cherry picked from commit 0772d804b32ed5a4176f45dd20c7ce1cb5004ca9)
---
.../maven/impl/model/DefaultModelBuilder.java | 3 +-
.../maven/it/MavenITgh2576ItrNotHonoredTest.java | 61 ++++++++++++++++++++++
.../org/apache/maven/it/TestSuiteOrdering.java | 1 +
.../gh-2576-itr-not-honored/consumer/.mvn/.gitkeep | 0
.../gh-2576-itr-not-honored/consumer/pom.xml | 15 ++++++
.../gh-2576-itr-not-honored/dep/.mvn/.gitkeep | 0
.../resources/gh-2576-itr-not-honored/dep/pom.xml | 22 ++++++++
.../gh-2576-itr-not-honored/parent/.mvn/.gitkeep | 0
.../gh-2576-itr-not-honored/parent/pom.xml | 8 +++
9 files changed, 109 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 877613eabe..4399409e02 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
@@ -524,7 +524,8 @@ public ModelBuilderException newModelBuilderException() {
}
public void mergeRepositories(Model model, boolean replace) {
- if (model.getRepositories().isEmpty()) {
+ if (model.getRepositories().isEmpty()
+ || InternalSession.from(session).getSession().isIgnoreArtifactDescriptorRepositories()) {
return;
}
// We need to interpolate the repositories before we can use them
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh2576ItrNotHonoredTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh2576ItrNotHonoredTest.java
new file mode 100644
index 0000000000..488ee59c5f
--- /dev/null
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh2576ItrNotHonoredTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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;
+
+/**
+ * This is a test set for <a href="https://github.com/apache/maven/issues/2576">GH-2576</a>.
+ * <p>
+ * The issue occurs when a project has a dependency which defines a custom repository needed to load its parent.
+ * The -itr option should not use any transitive repository, so this project should fail.
+ *
+ */
+class MavenITgh2576ItrNotHonoredTest extends AbstractMavenIntegrationTestCase {
+
+ MavenITgh2576ItrNotHonoredTest() {
+ super("[4.0.0,)");
+ }
+
+ @Test
+ void testItrNotHonored() throws Exception {
+ File testDir = extractResources("/gh-2576-itr-not-honored").getAbsoluteFile();
+
+ Verifier verifier = new Verifier(testDir.toString());
+ verifier.deleteArtifacts("org.apache.maven.its.gh2576");
+
+ verifier = new Verifier(new File(testDir, "parent").toString());
+ verifier.addCliArguments("install:install-file", "-Dfile=pom.xml", "-DpomFile=pom.xml", "-DlocalRepositoryPath=../repo/");
+ verifier.execute();
+ verifier.verifyErrorFreeLog();
+
+ // use maven 3 personality so that we don't flatten the pom
+ verifier = new Verifier(new File(testDir, "dep").toString());
+ verifier.addCliArguments("install", "-Dmaven.maven3Personality");
+ verifier.execute();
+ verifier.verifyErrorFreeLog();
+
+ verifier = new Verifier(new File(testDir, "consumer").toString());
+ verifier.addCliArguments("install", "-itr");
+ assertThrows(VerificationException.class, verifier::execute);
+ }
+}
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java b/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
index b64b6d16b5..20465b89fe 100644
--- a/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
@@ -103,6 +103,7 @@ public TestSuiteOrdering() {
* the tests are to finishing. Newer tests are also more likely to fail, so this is
* a fail fast technique as well.
*/
+ suite.addTestSuite(MavenITgh2576ItrNotHonoredTest.class);
suite.addTestSuite(MavenITgh11356InvalidTransitiveRepositoryTest.class);
suite.addTestSuite(MavenITgh11280DuplicateDependencyConsumerPomTest.class);
suite.addTestSuite(MavenITgh11162ConsumerPomScopesTest.class);
diff --git a/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/consumer/.mvn/.gitkeep b/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/consumer/.mvn/.gitkeep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/consumer/pom.xml b/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/consumer/pom.xml
new file mode 100644
index 0000000000..fd5afce185
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/consumer/pom.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.its.gh2576</groupId>
+ <artifactId>consumer</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.gh2576</groupId>
+ <artifactId>dep</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/dep/.mvn/.gitkeep b/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/dep/.mvn/.gitkeep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/dep/pom.xml b/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/dep/pom.xml
new file mode 100644
index 0000000000..866560cdf1
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/dep/pom.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.maven.its.gh2576</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>dep</artifactId>
+
+ <repositories>
+ <repository>
+ <id>foo</id>
+ <url>file:///${basedir}/../repo</url>
+ <snapshots>
+ <checksumPolicy>ignore</checksumPolicy>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+</project>
\ No newline at end of file
diff --git a/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/parent/.mvn/.gitkeep b/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/parent/.mvn/.gitkeep
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/parent/pom.xml b/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/parent/pom.xml
new file mode 100644
index 0000000000..31ac88e50d
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-2576-itr-not-honored/parent/pom.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.its.gh2576</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+</project>
\ No newline at end of file