Support transitive excludes in dependency-tools
Update spring-boot-dependency-tools to support transitive excludes. Transitive excludes are useful with Gradle which considers each dependency independently (see GRADLE-3061). Transitive excludes are supported by parsing the dependency-tree file from spring-boot-versions. See gh-1047
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
*
|
||||
* Licensed 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.springframework.boot.dependency.tools;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link DependenciesWithTransitiveExclusions}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class DependenciesWithTransitiveExclusionsTests {
|
||||
|
||||
@Test
|
||||
public void findsTransitiveExclusions() throws Exception {
|
||||
Dependencies source = new PomDependencies(getClass().getResourceAsStream(
|
||||
"test-effective-pom.xml"));
|
||||
DependencyTree tree = new DependencyTree(getClass().getResourceAsStream(
|
||||
"test-effective-pom-dependency-tree.txt"));
|
||||
DependenciesWithTransitiveExclusions dependencies = new DependenciesWithTransitiveExclusions(
|
||||
source, tree);
|
||||
assertExcludes(dependencies, "sample01", "[org.exclude:exclude01]");
|
||||
assertExcludes(source, "sample02", "[]");
|
||||
assertExcludes(dependencies, "sample02", "[org.exclude:exclude01]");
|
||||
}
|
||||
|
||||
private void assertExcludes(Dependencies dependencies, String artifactId,
|
||||
String expected) {
|
||||
Dependency dependency = dependencies.find("org.sample", artifactId);
|
||||
assertThat(dependency.getExclusions().toString(), equalTo(expected));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
*
|
||||
* Licensed 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.springframework.boot.dependency.tools;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.dependency.tools.DependencyTree;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link DependencyTree}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class DependencyTreeTests {
|
||||
|
||||
@Test
|
||||
public void parse() throws Exception {
|
||||
DependencyTree tree = new DependencyTree(getClass().getResourceAsStream(
|
||||
"sample-dependency-tree.txt"));
|
||||
assertThat(tree.getRoot().toString(), equalTo("org.springframework.boot:"
|
||||
+ "spring-boot-versions-dependency-tree:1.1.0.BUILD-SNAPSHOT"));
|
||||
assertThat(tree.getDependencies().size(), equalTo(204));
|
||||
assertThat(tree.get(0, 1).toString(), equalTo("org.slf4j:slf4j-api:1.7.6"));
|
||||
assertThat(tree.get(203).toString(), equalTo("org.springframework.security:"
|
||||
+ "spring-security-web:3.2.4.RELEASE"));
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
org.sample:sample:pom:1.0.0.BUILD-SNAPSHOT
|
||||
+- org.sample:sample01:jar:1.0.0:compile
|
||||
+- org.sample:sample02:jar:1.0.0:compile
|
||||
| +- (org.sample:sample01:jar:1.0.0:compile - omitted for duplicate)
|
||||
\- org.springframework.boot:spring-boot:jar:1.0.0.BUILD-SNAPSHOT:compile
|
||||
@@ -2,6 +2,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>org.sample</groupId>
|
||||
<artifactId>sample</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<properties>
|
||||
<sample.version>1.0.0</sample.version>
|
||||
|
||||
Reference in New Issue
Block a user