Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>