diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 70893a3a03..a2cd121a2c 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -81,6 +81,7 @@ public class IntegrationTestSuite // ------------------------------------------------------------------------------------------------------------- // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137 + suite.addTestSuite( MavenITmng4768NearestMatchConflictResolutionTest.class ); suite.addTestSuite( MavenITmng4750ResolvedMavenProjectDependencyArtifactsTest.class ); suite.addTestSuite( MavenITmng4747JavaAgentUsedByPluginTest.class ); // suite.addTestSuite( MavenITmng4745PluginVersionUpdateTest.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4768NearestMatchConflictResolutionTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4768NearestMatchConflictResolutionTest.java new file mode 100644 index 0000000000..6a55f4d78c --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4768NearestMatchConflictResolutionTest.java @@ -0,0 +1,114 @@ +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 org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; + +import java.io.File; +import java.util.List; + +/** + * This is a test set for MNG-4768. + * + * @author Benjamin Bentmann + */ +public class MavenITmng4768NearestMatchConflictResolutionTest + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng4768NearestMatchConflictResolutionTest() + { + super( "[2.0.9,)" ); + } + + // Ideally, all six permutations of the three direct dependencies should yield the same result... + + public void testitABD() + throws Exception + { + testit( "test-abd" ); + } + + public void testitADB() + throws Exception + { + requiresMavenVersion( "[4.0,)" ); + testit( "test-adb" ); + } + + public void testitBAD() + throws Exception + { + testit( "test-bad" ); + } + + public void testitBDA() + throws Exception + { + testit( "test-bda" ); + } + + public void testitDAB() + throws Exception + { + requiresMavenVersion( "[4.0,)" ); + testit( "test-dab" ); + } + + public void testitDBA() + throws Exception + { + testit( "test-dba" ); + } + + /** + * Verify that conflict resolution picks the nearest version that matches all hard constraints given by ranges. + * And for conflicting dependencies on distinct tree levels, "nearest" shouldn't be subject to the dependency + * order. + */ + private void testit( String test ) + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4768" ); + + Verifier verifier = newVerifier( new File( testDir, test ).getAbsolutePath() ); + verifier.setAutoclean( false ); + verifier.deleteDirectory( "target" ); + verifier.deleteArtifacts( "org.apache.maven.its.mng4768" ); + verifier.getCliOptions().add( "-s" ); + verifier.getCliOptions().add( "settings.xml" ); + verifier.filterFile( "../settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterProperties() ); + verifier.executeGoal( "validate" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + List classpath = verifier.loadLines( "target/classpath.txt", "UTF-8" ); + + assertTrue( test + " > " + classpath.toString(), classpath.contains( "a-2.0.jar" ) ); + assertTrue( test + " > " + classpath.toString(), classpath.contains( "b-0.1.jar" ) ); + assertTrue( test + " > " + classpath.toString(), classpath.contains( "c-0.1.jar" ) ); + assertTrue( test + " > " + classpath.toString(), classpath.contains( "d-0.1.jar" ) ); + + assertFalse( test + " > " + classpath.toString(), classpath.contains( "a-2.1.jar" ) ); + assertFalse( test + " > " + classpath.toString(), classpath.contains( "a-1.0.jar" ) ); + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/1.0/a-1.0.jar b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/1.0/a-1.0.jar new file mode 100644 index 0000000000..194267ed7c Binary files /dev/null and b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/1.0/a-1.0.jar differ diff --git a/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/1.0/a-1.0.pom b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/1.0/a-1.0.pom new file mode 100644 index 0000000000..2cde37cc7f --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/1.0/a-1.0.pom @@ -0,0 +1,36 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4768 + a + 1.0 + jar + + + + maven-core-it + file:///${basedir}/repo + + + diff --git a/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/2.0/a-2.0.jar b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/2.0/a-2.0.jar new file mode 100644 index 0000000000..be7a2eb0df Binary files /dev/null and b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/2.0/a-2.0.jar differ diff --git a/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/2.0/a-2.0.pom b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/2.0/a-2.0.pom new file mode 100644 index 0000000000..c2277b33f7 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/2.0/a-2.0.pom @@ -0,0 +1,36 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4768 + a + 2.0 + jar + + + + maven-core-it + file:///${basedir}/repo + + + diff --git a/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/2.1/a-2.1.jar b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/2.1/a-2.1.jar new file mode 100644 index 0000000000..e71e9218cb Binary files /dev/null and b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/2.1/a-2.1.jar differ diff --git a/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/2.1/a-2.1.pom b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/2.1/a-2.1.pom new file mode 100644 index 0000000000..a0fbe80c97 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/2.1/a-2.1.pom @@ -0,0 +1,36 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4768 + a + 2.1 + jar + + + + maven-core-it + file:///${basedir}/repo + + + diff --git a/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/maven-metadata.xml b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/maven-metadata.xml new file mode 100644 index 0000000000..77630d8c23 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/a/maven-metadata.xml @@ -0,0 +1,14 @@ + + + org.apache.maven.its.mng4768 + a + 1.0 + + + 1.0 + 2.0 + 2.1 + + 20100817162611 + + diff --git a/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/b/0.1/b-0.1.jar b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/b/0.1/b-0.1.jar new file mode 100644 index 0000000000..c68700cdb8 Binary files /dev/null and b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/b/0.1/b-0.1.jar differ diff --git a/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/b/0.1/b-0.1.pom b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/b/0.1/b-0.1.pom new file mode 100644 index 0000000000..f8d06e6206 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/b/0.1/b-0.1.pom @@ -0,0 +1,44 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4768 + b + 0.1 + jar + + + + maven-core-it + file:///${basedir}/repo + + + + + + org.apache.maven.its.mng4768 + c + 0.1 + + + diff --git a/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/c/0.1/c-0.1.jar b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/c/0.1/c-0.1.jar new file mode 100644 index 0000000000..c4bb1c7937 Binary files /dev/null and b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/c/0.1/c-0.1.jar differ diff --git a/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/c/0.1/c-0.1.pom b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/c/0.1/c-0.1.pom new file mode 100644 index 0000000000..0252e6ad56 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/c/0.1/c-0.1.pom @@ -0,0 +1,44 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4768 + c + 0.1 + jar + + + + maven-core-it + file:///${basedir}/repo + + + + + + org.apache.maven.its.mng4768 + a + [2.0,3) + + + diff --git a/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/d/0.1/d-0.1.jar b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/d/0.1/d-0.1.jar new file mode 100644 index 0000000000..ad91c0e3de Binary files /dev/null and b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/d/0.1/d-0.1.jar differ diff --git a/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/d/0.1/d-0.1.pom b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/d/0.1/d-0.1.pom new file mode 100644 index 0000000000..786923c14d --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4768/repo/org/apache/maven/its/mng4768/d/0.1/d-0.1.pom @@ -0,0 +1,44 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4768 + d + 0.1 + jar + + + + maven-core-it + file:///${basedir}/repo + + + + + + org.apache.maven.its.mng4768 + a + 2.0 + + + diff --git a/its/core-it-suite/src/test/resources/mng-4768/settings-template.xml b/its/core-it-suite/src/test/resources/mng-4768/settings-template.xml new file mode 100644 index 0000000000..f22a7f3570 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4768/settings-template.xml @@ -0,0 +1,43 @@ + + + + + + + + maven-core-it-repo + + + maven-core-it + @baseurl@/../repo + + ignore + + + false + + + + + + + maven-core-it-repo + + diff --git a/its/core-it-suite/src/test/resources/mng-4768/test-abd/pom.xml b/its/core-it-suite/src/test/resources/mng-4768/test-abd/pom.xml new file mode 100644 index 0000000000..5ec366dc60 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4768/test-abd/pom.xml @@ -0,0 +1,77 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4768 + abd + 0.1 + pom + + Maven Integration Test :: MNG-4768 :: ABD + + Verify that conflict resolution picks the nearest version that matches all hard constraints given by ranges. + And for conflicting dependencies on distinct tree levels, "nearest" shouldn't be subject to the dependency + order. + + + + + org.apache.maven.its.mng4768 + a + 1.0 + + + org.apache.maven.its.mng4768 + b + 0.1 + + + org.apache.maven.its.mng4768 + d + 0.1 + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-dependency-resolution + 2.1-SNAPSHOT + + target/classpath.txt + 1 + + + + resolve + validate + + compile + + + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-4768/test-adb/pom.xml b/its/core-it-suite/src/test/resources/mng-4768/test-adb/pom.xml new file mode 100644 index 0000000000..7b63ce0c26 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4768/test-adb/pom.xml @@ -0,0 +1,77 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4768 + adb + 0.1 + pom + + Maven Integration Test :: MNG-4768 :: ADB + + Verify that conflict resolution picks the nearest version that matches all hard constraints given by ranges. + And for conflicting dependencies on distinct tree levels, "nearest" shouldn't be subject to the dependency + order. + + + + + org.apache.maven.its.mng4768 + a + 1.0 + + + org.apache.maven.its.mng4768 + d + 0.1 + + + org.apache.maven.its.mng4768 + b + 0.1 + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-dependency-resolution + 2.1-SNAPSHOT + + target/classpath.txt + 1 + + + + resolve + validate + + compile + + + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-4768/test-bad/pom.xml b/its/core-it-suite/src/test/resources/mng-4768/test-bad/pom.xml new file mode 100644 index 0000000000..dd7f96cac2 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4768/test-bad/pom.xml @@ -0,0 +1,77 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4768 + bad + 0.1 + pom + + Maven Integration Test :: MNG-4768 :: BAD + + Verify that conflict resolution picks the nearest version that matches all hard constraints given by ranges. + And for conflicting dependencies on distinct tree levels, "nearest" shouldn't be subject to the dependency + order. + + + + + org.apache.maven.its.mng4768 + b + 0.1 + + + org.apache.maven.its.mng4768 + a + 1.0 + + + org.apache.maven.its.mng4768 + d + 0.1 + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-dependency-resolution + 2.1-SNAPSHOT + + target/classpath.txt + 1 + + + + resolve + validate + + compile + + + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-4768/test-bda/pom.xml b/its/core-it-suite/src/test/resources/mng-4768/test-bda/pom.xml new file mode 100644 index 0000000000..a925c20b4c --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4768/test-bda/pom.xml @@ -0,0 +1,77 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4768 + bda + 0.1 + pom + + Maven Integration Test :: MNG-4768 :: BDA + + Verify that conflict resolution picks the nearest version that matches all hard constraints given by ranges. + And for conflicting dependencies on distinct tree levels, "nearest" shouldn't be subject to the dependency + order. + + + + + org.apache.maven.its.mng4768 + b + 0.1 + + + org.apache.maven.its.mng4768 + d + 0.1 + + + org.apache.maven.its.mng4768 + a + 1.0 + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-dependency-resolution + 2.1-SNAPSHOT + + target/classpath.txt + 1 + + + + resolve + validate + + compile + + + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-4768/test-dab/pom.xml b/its/core-it-suite/src/test/resources/mng-4768/test-dab/pom.xml new file mode 100644 index 0000000000..de6683a117 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4768/test-dab/pom.xml @@ -0,0 +1,77 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4768 + dab + 0.1 + pom + + Maven Integration Test :: MNG-4768 :: DAB + + Verify that conflict resolution picks the nearest version that matches all hard constraints given by ranges. + And for conflicting dependencies on distinct tree levels, "nearest" shouldn't be subject to the dependency + order. + + + + + org.apache.maven.its.mng4768 + d + 0.1 + + + org.apache.maven.its.mng4768 + a + 1.0 + + + org.apache.maven.its.mng4768 + b + 0.1 + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-dependency-resolution + 2.1-SNAPSHOT + + target/classpath.txt + 1 + + + + resolve + validate + + compile + + + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-4768/test-dba/pom.xml b/its/core-it-suite/src/test/resources/mng-4768/test-dba/pom.xml new file mode 100644 index 0000000000..38e2f37fa2 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4768/test-dba/pom.xml @@ -0,0 +1,77 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4768 + dba + 0.1 + pom + + Maven Integration Test :: MNG-4768 :: DBA + + Verify that conflict resolution picks the nearest version that matches all hard constraints given by ranges. + And for conflicting dependencies on distinct tree levels, "nearest" shouldn't be subject to the dependency + order. + + + + + org.apache.maven.its.mng4768 + d + 0.1 + + + org.apache.maven.its.mng4768 + b + 0.1 + + + org.apache.maven.its.mng4768 + a + 1.0 + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-dependency-resolution + 2.1-SNAPSHOT + + target/classpath.txt + 1 + + + + resolve + validate + + compile + + + + + + +