mirror of https://github.com/apache/maven.git
[REGRESSION] Maven fails to use <repositories> section from dependency when resolving transitive dependencies in some cases
This commit is contained in:
parent
cf41940d41
commit
6700a88209
|
@ -107,6 +107,7 @@ public class IntegrationTestSuite
|
|||
// -------------------------------------------------------------------------------------------------------------
|
||||
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
|
||||
|
||||
suite.addTestSuite( MavenITmng6759TransitiveDependencyRepositoriesTest.class );
|
||||
suite.addTestSuite( MavenITmng6720FailFastTest.class );
|
||||
suite.addTestSuite( MavenITmng6506PackageAnnotationTest.class );
|
||||
suite.addTestSuite( MavenITmng6256SpecialCharsAlternatePOMLocation.class );
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package org.apache.maven.it;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
/**
|
||||
* This is a test for <a href="https://issues.apache.org/jira/browse/MNG-6759">MNG-6759</a>.
|
||||
*/
|
||||
public class MavenITmng6759TransitiveDependencyRepositoriesTest extends AbstractMavenIntegrationTestCase {
|
||||
|
||||
private final String projectBaseDir = "/mng-6759-transitive-dependency-repositories";
|
||||
|
||||
public MavenITmng6759TransitiveDependencyRepositoriesTest() {
|
||||
super( "(,3.6.2),(3.6.2,)" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a project with a dependency graph like A -> B -> C,
|
||||
* where C is in a non-Central repository should use B's {@literal <repositories>} to resolve C.
|
||||
*/
|
||||
public void testTransitiveDependenciesAccountForRepositoriesListedByDependencyTrailPredecessor() throws Exception {
|
||||
URI customRepoUri = installDependencyCInCustomRepo();
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), projectBaseDir );
|
||||
|
||||
Verifier verifier = newVerifier( testDir.getAbsolutePath() );
|
||||
|
||||
verifier.addCliOption( "-Dcustom.repo.uri=" + customRepoUri );
|
||||
verifier.executeGoal( "package" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
}
|
||||
|
||||
private URI installDependencyCInCustomRepo() throws Exception {
|
||||
File dependencyCProjectDir = ResourceExtractor.simpleExtractResources( getClass(), projectBaseDir + "/dependency-in-custom-repo" );
|
||||
URI customRepoUri = new File(new File(dependencyCProjectDir, "target" ), "repo" ).toURI();
|
||||
Verifier verifier = newVerifier( dependencyCProjectDir.getAbsolutePath() );
|
||||
|
||||
verifier.deleteDirectory( "target" );
|
||||
verifier.addCliOption( "-DaltDeploymentRepository=customRepo::default::" + customRepoUri );
|
||||
verifier.executeGoal( "deploy" );
|
||||
verifier.verifyErrorFreeLog();
|
||||
return customRepoUri;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>mng-6759-transitive-dependency-repositories</groupId>
|
||||
<artifactId>dependency-in-custom-repo</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>mng-6759-transitive-dependency-repositories</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<artifactId>module1</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mng-6759-transitive-dependency-repositories</groupId>
|
||||
<artifactId>module2</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>mng-6759-transitive-dependency-repositories</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<artifactId>module2</artifactId>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>customRepo</id>
|
||||
<url>${custom.repo.uri}</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mng-6759-transitive-dependency-repositories</groupId>
|
||||
<artifactId>dependency-in-custom-repo</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>mng-6759-transitive-dependency-repositories</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>module1</module>
|
||||
<module>module2</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<!-- This plugin resolves dependencies via DefaultLegacyArtifactCollector, which hits the buggy code in MavenMetadataSource -->
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>mng-6759-resolves-project-dependencies-plugin</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>resolve</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,70 @@
|
|||
<?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" 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>
|
||||
<artifactId>maven-it-plugins</artifactId>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mng-6759-resolves-project-dependencies-plugin</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
|
||||
<properties>
|
||||
<maven-version>3.0</maven-version>
|
||||
</properties>
|
||||
|
||||
<name>Maven IT Plugin :: mng-6759 plugin</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.shared</groupId>
|
||||
<artifactId>maven-artifact-resolver</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>${maven-version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||
<artifactId>maven-plugin-annotations</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>${maven-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
<version>${maven-version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,66 @@
|
|||
package org.apache.maven.its.mng6759.plugin;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.apache.maven.ProjectDependenciesResolver;
|
||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.Component;
|
||||
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
/**
|
||||
* Resolves the project dependency tree
|
||||
*/
|
||||
@Mojo( name = "resolve", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true )
|
||||
public class TestMojo
|
||||
extends AbstractMojo
|
||||
{
|
||||
|
||||
@Parameter( defaultValue = "${project}", readonly = true, required = true )
|
||||
private MavenProject project;
|
||||
|
||||
@Parameter( defaultValue = "${session}", readonly = true, required = true )
|
||||
private MavenSession mavenSession;
|
||||
|
||||
@Component( hint = "default" )
|
||||
protected ProjectDependenciesResolver dependencyResolver;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
dependencyResolver.resolve( project, Arrays.asList( "test" ), mavenSession );
|
||||
}
|
||||
catch ( ArtifactResolutionException | ArtifactNotFoundException e )
|
||||
{
|
||||
throw new MojoExecutionException( e.getMessage(), e );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -83,6 +83,7 @@ under the License.
|
|||
<module>mng5805-plugin</module>
|
||||
<module>mng5805-plugin-dep</module>
|
||||
<module>mng5958-extension</module>
|
||||
<module>mng-6759-resolves-project-dependencies-plugin</module>
|
||||
</modules>
|
||||
|
||||
<scm>
|
||||
|
|
Loading…
Reference in New Issue