Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-7982] IT’s for transitive dependency management #379

Closed
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 @@ -29,6 +29,7 @@
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-4720">MNG-4720</a>.
*
* @author Benjamin Bentmann
* @author Ddiier Loiseau
*/
public class MavenITmng4720DependencyManagementExclusionMergeTest extends AbstractMavenIntegrationTestCase {

Expand All @@ -39,11 +40,13 @@ public MavenITmng4720DependencyManagementExclusionMergeTest() {
/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I update the super() above? Maybe keep the old test for [2.0.6,4.0.0) and move these changes to a new test for [4.0.0,)?

I don’t know how this test suite is used for previous releases…

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really used anymore. At least, we branched for Maven 3.x, not sure how we'll handle things for 4.0, 4.1, etc..., but I was actually considering merging ITs into maven to ease. I don't really see any good reason not to do that.

* Verify the effective exclusions applied during transitive dependency resolution when both the regular
* dependency section and dependency management declare exclusions for a particular dependency.
* <p>
* By default, the dependency management of transitive dependencies is now taken into account.
*
* @throws Exception in case of failure
*/
@Test
public void testit() throws Exception {
public void testitWithTransitiveDependencyManager() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4720");

Verifier verifier = newVerifier(testDir.getAbsolutePath());
Expand All @@ -63,7 +66,41 @@ public void testit() throws Exception {

assertFalse(classpath.toString(), classpath.contains("b-0.1.jar"));

// should better have been excluded as well, now it's a matter of backward-compat
// dependency management in a excludes d
assertFalse(classpath.toString(), classpath.contains("d-0.1.jar"));
}

/**
* Verify the effective exclusions applied during transitive dependency resolution when both the regular
* dependency section and dependency management declare exclusions for a particular dependency.
* <p>
* This tests the same behaviour with dependency manager transitivity disabled.
*
* @throws Exception in case of failure
*/
@Test
public void testitWithTransitiveDependencyManagerDisabled() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4720");

Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.setAutoclean(false);
verifier.deleteArtifacts("org.apache.maven.its.mng4720");
verifier.addCliArgument("-s");
verifier.addCliArgument("settings.xml");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("-Dmaven.resolver.dependencyManagerTransitivity=false");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();

List<String> classpath = verifier.loadLines("target/classpath.txt", "UTF-8");

assertTrue(classpath.toString(), classpath.contains("a-0.1.jar"));
assertTrue(classpath.toString(), classpath.contains("c-0.1.jar"));

assertFalse(classpath.toString(), classpath.contains("b-0.1.jar"));

// backward-compat: dependency management is ignored except in root pom
assertTrue(classpath.toString(), classpath.contains("d-0.1.jar"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
* 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.List;

import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;

/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-7982">MNG-7982</a>.
*
* @author Didier Loiseau
*/
public class MavenITmng7982DependencyManagementTransitivityTest extends AbstractMavenIntegrationTestCase {

public MavenITmng7982DependencyManagementTransitivityTest() {
super("[4.0.0-beta-5,)");
}

/**
* Verify the effective dependency versions determined when using the transitive dependency management (default).
* <p>
* By default, the dependency management of transitive dependencies should be taken into account.
*
* @throws Exception in case of failure
*/
@Test
public void testitWithTransitiveDependencyManager() throws Exception {
File testDir =
ResourceExtractor.simpleExtractResources(getClass(), "/mng-7982-transitive-dependency-management");

Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.deleteArtifacts("org.apache.maven.its.mng7982");
verifier.addCliArgument("-s");
verifier.addCliArgument("settings.xml");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("verify");
verifier.execute();
verifier.verifyErrorFreeLog();

List<String> bClasspath = verifier.loadLines("b/target/classpath.txt", "UTF-8");
assertTrue(bClasspath.toString(), bClasspath.contains("a-1.jar"));
assertFalse(bClasspath.toString(), bClasspath.contains("a-2.jar"));

List<String> cClasspath = verifier.loadLines("c/target/classpath.txt", "UTF-8");
assertTrue(cClasspath.toString(), cClasspath.contains("b-1.jar"));
assertFalse(cClasspath.toString(), cClasspath.contains("a-1.jar"));
assertTrue(cClasspath.toString(), cClasspath.contains("a-2.jar"));

List<String> dClasspath = verifier.loadLines("d/target/classpath.txt", "UTF-8");
assertTrue(dClasspath.toString(), dClasspath.contains("c-1.jar"));
assertTrue(dClasspath.toString(), dClasspath.contains("b-1.jar"));
assertFalse(dClasspath.toString(), dClasspath.contains("a-1.jar"));
assertTrue(dClasspath.toString(), dClasspath.contains("a-2.jar"));

List<String> eClasspath = verifier.loadLines("e/target/classpath.txt", "UTF-8");
assertTrue(eClasspath.toString(), eClasspath.contains("d-1.jar"));
assertTrue(eClasspath.toString(), eClasspath.contains("c-1.jar"));
assertTrue(eClasspath.toString(), eClasspath.contains("b-1.jar"));
assertFalse(eClasspath.toString(), eClasspath.contains("a-1.jar"));
assertTrue(eClasspath.toString(), eClasspath.contains("a-2.jar"));
}

/**
* Verify the effective dependency versions determined when disabling the transitive dependency management (Maven 2/3 behavior).
* <p>
* When transitivity is disabled, the dependency management of transitive dependencies should is ignored.
*
* @throws Exception in case of failure
*/
@Test
public void testitWithTransitiveDependencyManagerDisabled() throws Exception {
File testDir =
ResourceExtractor.simpleExtractResources(getClass(), "/mng-7982-transitive-dependency-management");

Verifier verifier = newVerifier(testDir.getAbsolutePath());
verifier.deleteArtifacts("org.apache.maven.its.mng7982");
verifier.addCliArgument("-s");
verifier.addCliArgument("settings.xml");
verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8");
verifier.addCliArgument("verify");
verifier.addCliArgument("-Dmaven.resolver.dependencyManagerTransitivity=false");
verifier.execute();
verifier.verifyErrorFreeLog();

List<String> bClasspath = verifier.loadLines("b/target/classpath.txt", "UTF-8");
assertTrue(bClasspath.toString(), bClasspath.contains("a-1.jar"));
assertFalse(bClasspath.toString(), bClasspath.contains("a-2.jar"));

List<String> cClasspath = verifier.loadLines("c/target/classpath.txt", "UTF-8");
assertTrue(cClasspath.toString(), cClasspath.contains("b-1.jar"));
assertFalse(cClasspath.toString(), cClasspath.contains("a-1.jar"));
assertTrue(cClasspath.toString(), cClasspath.contains("a-2.jar"));

List<String> dClasspath = verifier.loadLines("d/target/classpath.txt", "UTF-8");
assertTrue(dClasspath.toString(), dClasspath.contains("c-1.jar"));
assertTrue(dClasspath.toString(), dClasspath.contains("b-1.jar"));
// dependency management of c is ignored
assertTrue(dClasspath.toString(), dClasspath.contains("a-1.jar"));
assertFalse(dClasspath.toString(), dClasspath.contains("a-2.jar"));

List<String> eClasspath = verifier.loadLines("e/target/classpath.txt", "UTF-8");
assertTrue(eClasspath.toString(), eClasspath.contains("d-1.jar"));
assertTrue(eClasspath.toString(), eClasspath.contains("c-1.jar"));
assertTrue(eClasspath.toString(), eClasspath.contains("b-1.jar"));
// dependency management of c is ignored
assertTrue(dClasspath.toString(), dClasspath.contains("a-1.jar"));
assertFalse(dClasspath.toString(), dClasspath.contains("a-2.jar"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?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.1.0</modelVersion>

<parent />

<groupId>org.apache.maven.its.mng7982</groupId>
<artifactId>b</artifactId>
<version>1</version>

<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng7982</groupId>
<artifactId>a</artifactId>
<version>1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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.1.0</modelVersion>

<parent />

<groupId>org.apache.maven.its.mng7982</groupId>
<artifactId>c</artifactId>
<version>1</version>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng7982</groupId>
<artifactId>a</artifactId>
<version>2</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng7982</groupId>
<artifactId>b</artifactId>
<version>1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?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.1.0</modelVersion>

<parent />

<groupId>org.apache.maven.its.mng7982</groupId>
<artifactId>d</artifactId>
<version>1</version>

<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng7982</groupId>
<artifactId>c</artifactId>
<version>1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?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.1.0</modelVersion>

<parent />

<groupId>org.apache.maven.its.mng7982</groupId>
<artifactId>e</artifactId>
<version>1</version>

<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng7982</groupId>
<artifactId>d</artifactId>
<version>1</version>
</dependency>
</dependencies>
</project>
Loading
Loading