Merge branch 'master' into mng-6118-submodule-invocation
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
index 6f6e419..50367ea 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
@@ -109,6 +109,7 @@
suite.addTestSuite( MavenITmng6118SubmoduleInvocation.class );
suite.addTestSuite( MavenITmng6972AllowAccessToGraphPackageTest.class );
+ suite.addTestSuite( MavenITmng6772NestedImportScopeRepositoryOverride.class );
suite.addTestSuite( MavenITmng6759TransitiveDependencyRepositoriesTest.class );
suite.addTestSuite( MavenITmng6720FailFastTest.class );
suite.addTestSuite( MavenITmng6656BuildConsumer.class );
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6772NestedImportScopeRepositoryOverride.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6772NestedImportScopeRepositoryOverride.java
new file mode 100644
index 0000000..dd44d35
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng6772NestedImportScopeRepositoryOverride.java
@@ -0,0 +1,95 @@
+package org.apache.maven.it;
+
+import java.io.File;
+
+/*
+ * 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.util.ResourceExtractor;
+
+/**
+ * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-6772">MNG-6772</a>:
+ *
+ * The test POM references an import scope POM, which also has a dependency on an import scope POM.
+ *
+ * Both import POMs can only be found in the repository defined in the test POM.
+ * It has a parent POM that defines the same repository with a different location.
+ * The test confirms that the dominant repository definition (child) wins while resolving the import POMs.
+ *
+ */
+public class MavenITmng6772NestedImportScopeRepositoryOverride
+ extends AbstractMavenIntegrationTestCase
+{
+
+ public MavenITmng6772NestedImportScopeRepositoryOverride()
+ {
+ super( "(,3.7.0),[3.7.0,)" );
+ }
+
+ // This will test the behavior using ProjectModelResolver
+ public void testitInProject()
+ throws Exception
+ {
+ final File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6772-override-in-project" );
+
+ final Verifier verifier = newVerifier( testDir.getAbsolutePath(), null );
+ overrideGlobalSettings( testDir, verifier );
+ verifier.deleteArtifacts( "org.apache.maven.its.mng6772" );
+
+ verifier.filterFile( "pom-template.xml", "pom.xml", "UTF-8", verifier.newDefaultFilterProperties() );
+
+ verifier.executeGoal( "validate" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+ }
+
+ // This will test the behavior using DefaultModelResolver
+ public void testitInDependency()
+ throws Exception
+ {
+ final File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6772-override-in-dependency" );
+
+ final Verifier verifier = newVerifier( testDir.getAbsolutePath(), null );
+ overrideGlobalSettings( testDir, verifier );
+ verifier.deleteArtifacts( "org.apache.maven.its.mng6772" );
+
+ verifier.filterFile( "pom-template.xml", "pom.xml", "UTF-8", verifier.newDefaultFilterProperties() );
+
+ verifier.executeGoal( "compile" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+ }
+
+ // central must not be defined in any settings.xml or super POM will never be in play.
+ private void overrideGlobalSettings( final File testDir, final Verifier verifier )
+ {
+ final File settingsFile = new File( testDir, "settings-override.xml" );
+ final String path = settingsFile.getAbsolutePath();
+ verifier.getCliOptions().add( "--global-settings" );
+ if ( path.indexOf( ' ' ) < 0 )
+ {
+ verifier.getCliOptions().add( path );
+ }
+ else
+ {
+ verifier.getCliOptions().add( '"' + path + '"' );
+ }
+ }
+
+}
diff --git a/core-it-suite/src/test/resources/mng-6772-override-in-dependency/pom-template.xml b/core-it-suite/src/test/resources/mng-6772-override-in-dependency/pom-template.xml
new file mode 100644
index 0000000..9120768
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6772-override-in-dependency/pom-template.xml
@@ -0,0 +1,50 @@
+<?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>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.mng6772</groupId>
+ <artifactId>test</artifactId>
+ <version>0.1</version>
+ <packaging>jar</packaging>
+
+ <name>Maven Integration Test :: MNG-6772</name>
+ <description>
+ Checks that overriding the central repository always wins over the super POM.
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.mng6772</groupId>
+ <artifactId>dependency</artifactId>
+ <version>0.1</version>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>central</id>
+ <url>@baseurl@/repo</url>
+ </repository>
+ </repositories>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-6772-override-in-dependency/repo/org/apache/maven/its/mng6772/a/0.1/a-0.1.pom b/core-it-suite/src/test/resources/mng-6772-override-in-dependency/repo/org/apache/maven/its/mng6772/a/0.1/a-0.1.pom
new file mode 100644
index 0000000..5420f7b
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6772-override-in-dependency/repo/org/apache/maven/its/mng6772/a/0.1/a-0.1.pom
@@ -0,0 +1,41 @@
+<?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>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.mng6772</groupId>
+ <artifactId>a</artifactId>
+ <version>0.1</version>
+ <packaging>pom</packaging>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.mng6772</groupId>
+ <artifactId>b</artifactId>
+ <version>0.1</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-6772-override-in-dependency/repo/org/apache/maven/its/mng6772/b/0.1/b-0.1.pom b/core-it-suite/src/test/resources/mng-6772-override-in-dependency/repo/org/apache/maven/its/mng6772/b/0.1/b-0.1.pom
new file mode 100644
index 0000000..5cc3486
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6772-override-in-dependency/repo/org/apache/maven/its/mng6772/b/0.1/b-0.1.pom
@@ -0,0 +1,39 @@
+<?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>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.mng6772</groupId>
+ <artifactId>b</artifactId>
+ <version>0.1</version>
+ <packaging>pom</packaging>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.mng6772</groupId>
+ <artifactId>c</artifactId>
+ <version>0.1</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-6772-override-in-dependency/repo/org/apache/maven/its/mng6772/dependency/0.1/dependency-0.1.pom b/core-it-suite/src/test/resources/mng-6772-override-in-dependency/repo/org/apache/maven/its/mng6772/dependency/0.1/dependency-0.1.pom
new file mode 100644
index 0000000..5a6b1e1
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6772-override-in-dependency/repo/org/apache/maven/its/mng6772/dependency/0.1/dependency-0.1.pom
@@ -0,0 +1,41 @@
+<?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>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.mng6772</groupId>
+ <artifactId>dependency</artifactId>
+ <version>0.1</version>
+ <packaging>pom</packaging>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.mng6772</groupId>
+ <artifactId>a</artifactId>
+ <version>0.1</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-6772-override-in-dependency/settings-override.xml b/core-it-suite/src/test/resources/mng-6772-override-in-dependency/settings-override.xml
new file mode 100644
index 0000000..662d3f0
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6772-override-in-dependency/settings-override.xml
@@ -0,0 +1,23 @@
+<?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.
+-->
+
+<settings>
+</settings>
diff --git a/core-it-suite/src/test/resources/mng-6772-override-in-project/pom-template.xml b/core-it-suite/src/test/resources/mng-6772-override-in-project/pom-template.xml
new file mode 100644
index 0000000..19149cd
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6772-override-in-project/pom-template.xml
@@ -0,0 +1,53 @@
+<?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>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.mng6772</groupId>
+ <artifactId>test</artifactId>
+ <version>0.1</version>
+ <packaging>jar</packaging>
+
+ <name>Maven Integration Test :: MNG-6772</name>
+ <description>
+ Checks that overriding the central repository always wins over the super POM.
+ </description>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.mng6772</groupId>
+ <artifactId>a</artifactId>
+ <version>0.1</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <repositories>
+ <repository>
+ <id>central</id>
+ <url>@baseurl@/repo</url>
+ </repository>
+ </repositories>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-6772-override-in-project/repo/org/apache/maven/its/mng6772/a/0.1/a-0.1.pom b/core-it-suite/src/test/resources/mng-6772-override-in-project/repo/org/apache/maven/its/mng6772/a/0.1/a-0.1.pom
new file mode 100644
index 0000000..5420f7b
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6772-override-in-project/repo/org/apache/maven/its/mng6772/a/0.1/a-0.1.pom
@@ -0,0 +1,41 @@
+<?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>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.mng6772</groupId>
+ <artifactId>a</artifactId>
+ <version>0.1</version>
+ <packaging>pom</packaging>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.mng6772</groupId>
+ <artifactId>b</artifactId>
+ <version>0.1</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-6772-override-in-project/repo/org/apache/maven/its/mng6772/b/0.1/b-0.1.pom b/core-it-suite/src/test/resources/mng-6772-override-in-project/repo/org/apache/maven/its/mng6772/b/0.1/b-0.1.pom
new file mode 100644
index 0000000..5cc3486
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6772-override-in-project/repo/org/apache/maven/its/mng6772/b/0.1/b-0.1.pom
@@ -0,0 +1,39 @@
+<?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>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.mng6772</groupId>
+ <artifactId>b</artifactId>
+ <version>0.1</version>
+ <packaging>pom</packaging>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.mng6772</groupId>
+ <artifactId>c</artifactId>
+ <version>0.1</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-6772-override-in-project/settings-override.xml b/core-it-suite/src/test/resources/mng-6772-override-in-project/settings-override.xml
new file mode 100644
index 0000000..662d3f0
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-6772-override-in-project/settings-override.xml
@@ -0,0 +1,23 @@
+<?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.
+-->
+
+<settings>
+</settings>
diff --git a/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java b/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java
index 17d4d3d..abe02a3 100644
--- a/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java
+++ b/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/AbstractMavenIntegrationTestCase.java
@@ -29,8 +29,13 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -579,7 +584,8 @@
if ( matchesVersionRange( "(3.2.5,)" ) )
{
- verifier.getSystemProperties().put( "maven.multiModuleProjectDirectory", basedir );
+ String multiModuleProjectDirectory = findMultiModuleProjectDirectory( basedir );
+ verifier.getSystemProperties().put( "maven.multiModuleProjectDirectory", multiModuleProjectDirectory );
}
try
@@ -608,6 +614,36 @@
return verifier;
}
+ private boolean hasDotMvnSubfolder( Path path )
+ {
+ final Path probablySubfolder = path.resolve( ".mvn" );
+ return Files.exists( probablySubfolder ) && Files.isDirectory( probablySubfolder );
+ }
+
+ private String findMultiModuleProjectDirectory( String basedir )
+ {
+ Path path = Paths.get( basedir );
+ Path result = path;
+
+ Collection<Path> fileSystemRoots = new ArrayList<>();
+ for ( Path root : path.getFileSystem().getRootDirectories() )
+ {
+ fileSystemRoots.add( root );
+ }
+
+ while ( !fileSystemRoots.contains( path ) )
+ {
+ if ( hasDotMvnSubfolder( path ) )
+ {
+ result = path;
+ break;
+ }
+ path = path.getParent();
+ }
+
+ return result.toString();
+ }
+
public static void assertCanonicalFileEquals( String message, File expected, File actual )
throws IOException
{
diff --git a/pom.xml b/pom.xml
index b15063d..dcef45c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,7 +50,7 @@
</scm>
<ciManagement>
<system>Jenkins</system>
- <url>https://builds.apache.org/job/maven-box/job/maven/</url>
+ <url>https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven/</url>
</ciManagement>
<issueManagement>
<system>jira</system>