From 16a7489f467f0e6d6053a2c342c03bcf41a0df86 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 15 Jun 2023 20:49:41 +0200 Subject: [PATCH] [MNG-5600] Dependency management import should support exclusions. (#269) Co-authored-by: Christian Schulte --- ...endencyManagementImportExclusionsTest.java | 75 +++++++++++++++++ .../apache/maven/it/TestSuiteOrdering.java | 1 + .../resources/mng-5600/exclusions/pom.xml | 80 +++++++++++++++++++ .../apache/maven/its/mng5600/bom/0/bom-0.pom | 44 ++++++++++ .../resources/mng-5600/settings-template.xml | 43 ++++++++++ 5 files changed, 243 insertions(+) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5600DependencyManagementImportExclusionsTest.java create mode 100644 its/core-it-suite/src/test/resources/mng-5600/exclusions/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-5600/repo/org/apache/maven/its/mng5600/bom/0/bom-0.pom create mode 100644 its/core-it-suite/src/test/resources/mng-5600/settings-template.xml diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5600DependencyManagementImportExclusionsTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5600DependencyManagementImportExclusionsTest.java new file mode 100644 index 0000000000..d75fc79707 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5600DependencyManagementImportExclusionsTest.java @@ -0,0 +1,75 @@ +/* + * 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 java.util.Properties; + +import org.apache.maven.shared.verifier.Verifier; +import org.apache.maven.shared.verifier.util.ResourceExtractor; +import org.junit.jupiter.api.Test; + +/** + * [MNG-5600] Dependency management import should support exclusions. + * + * @author Christian Schulte + */ +class MavenITmng5600DependencyManagementImportExclusionsTest extends AbstractMavenIntegrationTestCase { + + MavenITmng5600DependencyManagementImportExclusionsTest() { + super("[4.0.0-alpha-5,)"); + } + + @Test + public void testCanExcludeDependenciesFromImport() throws Exception { + final File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-5600/exclusions"); + + Verifier verifier = newVerifier(testDir.getAbsolutePath()); + verifier.setAutoclean(false); + verifier.filterFile("../settings-template.xml", "settings.xml", "UTF-8", verifier.newDefaultFilterMap()); + + verifier.addCliArguments("-s", "settings.xml"); + verifier.addCliArguments("clean", "verify"); + verifier.execute(); + verifier.verifyErrorFreeLog(); + + final Properties properties = verifier.loadProperties("target/project.properties"); + assertEquals("1", properties.getProperty("project.dependencyManagement.dependencies")); + assertEquals( + "commons-lang:commons-lang:jar", + properties.getProperty("project.dependencyManagement.dependencies.0.managementKey")); + + assertEquals("2", properties.getProperty("project.dependencyManagement.dependencies.0.exclusions")); + assertEquals( + "commons-io", + properties.getProperty("project.dependencyManagement.dependencies.0.exclusions.0.groupId")); + + assertEquals( + "commons-io", + properties.getProperty("project.dependencyManagement.dependencies.0.exclusions.0.artifactId")); + + assertEquals( + "commons-logging", + properties.getProperty("project.dependencyManagement.dependencies.0.exclusions.1.groupId")); + + assertEquals( + "commons-logging", + properties.getProperty("project.dependencyManagement.dependencies.0.exclusions.1.artifactId")); + } +} 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 eb82334536..c8ed837600 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 @@ -120,6 +120,7 @@ public class TestSuiteOrdering implements ClassOrderer { * the tests are to finishing. Newer tests are also more likely to fail, so this is * a fail fast technique as well. */ + suite.addTestSuite(MavenITmng5600DependencyManagementImportExclusionsTest.class); suite.addTestSuite(MavenITmng7740ConsumerBuildShouldCleanUpOldFilesTest.class); suite.addTestSuite(MavenITmng7587Jsr330.class); suite.addTestSuite(MavenITmng7038RootdirTest.class); diff --git a/its/core-it-suite/src/test/resources/mng-5600/exclusions/pom.xml b/its/core-it-suite/src/test/resources/mng-5600/exclusions/pom.xml new file mode 100644 index 0000000000..4c8c9eec55 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5600/exclusions/pom.xml @@ -0,0 +1,80 @@ + + + + 4.0.0 + + org.apache.maven.its.mng5600 + 0 + 20160619 + pom + + Maven Integration Test :: MNG-5600 + + Tests that dependency management import exclusions are supported. + + + + + org.apache.maven.its.mng5600 + bom + 0 + pom + import + + + + commons-io + commons-io + + + + commons-logging + commons-logging + + + + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-expression + 2.1-SNAPSHOT + + + + eval + + verify + + + project/dependencyManagement + + ${project.build.directory}/project.properties + + + + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-5600/repo/org/apache/maven/its/mng5600/bom/0/bom-0.pom b/its/core-it-suite/src/test/resources/mng-5600/repo/org/apache/maven/its/mng5600/bom/0/bom-0.pom new file mode 100644 index 0000000000..6598212c4a --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5600/repo/org/apache/maven/its/mng5600/bom/0/bom-0.pom @@ -0,0 +1,44 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng5600 + bom + 0 + pom + + + + + commons-io + commons-io + 2.5 + + + commons-lang + commons-lang + 2.6 + + + + diff --git a/its/core-it-suite/src/test/resources/mng-5600/settings-template.xml b/its/core-it-suite/src/test/resources/mng-5600/settings-template.xml new file mode 100644 index 0000000000..f22a7f3570 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5600/settings-template.xml @@ -0,0 +1,43 @@ + + + + + + + + maven-core-it-repo + + + maven-core-it + @baseurl@/../repo + + ignore + + + false + + + + + + + maven-core-it-repo + +