From 307fbba9e4b88ea9938817a64d840d82d6a8cd72 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 20 May 2014 14:33:19 +0100 Subject: [PATCH] Use spring-boot-dependencies as spring-boot-dependency-tools' parent Previously spring-boot-dependency-tools used spring-boot-tools as its parent. This meant that it inherited spring-boot-parents' dependency management that we did not want to expose to applications. The solution to this was to generate the effective pom and then filter out any thing that did not appear in spring-boot-dependencies' pom. This filtering had to unwanted side-effect of breaking bom imports: the effective pom would contain the dependency management from the imported bom, but this would be filtered out as the entries didn't appear in spring-boot-dependencies' pom. This commit updates spring-boot-dependency-tools to use spring-boot-dependencies as its parent. This means that its effective pom contains the desired dependency management and nothing more, allowing the filtering logic to be removed. The use of Spring Security's bom has been reinstated as it will now work as intended and versions for its modules will be available in the CLI and via the Gradle plugin. Closes #825 Fixes #838 --- spring-boot-dependencies/pom.xml | 54 ++----------------- .../spring-boot-dependency-tools/pom.xml | 15 +++++- .../tools/PomManagedDependencies.java | 33 ++---------- .../PropertiesFileManagedDependencies.java | 6 +-- .../tools/VersionManagedDependencies.java | 4 +- .../tools/PomManagedDependenciesTests.java | 10 +--- .../tools/test-dependencies-pom.xml | 36 ------------- .../dependency/tools/test-effective-pom.xml | 5 -- 8 files changed, 28 insertions(+), 135 deletions(-) delete mode 100644 spring-boot-tools/spring-boot-dependency-tools/src/test/resources/org/springframework/boot/dependency/tools/test-dependencies-pom.xml diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index a1d21e314e7..2a4de7ab2b3 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -1015,58 +1015,10 @@ org.springframework.security - spring-security-acl - ${spring-security.version} - - - org.springframework.security - spring-security-aspects - ${spring-security.version} - - - org.springframework.security - spring-security-cas - ${spring-security.version} - - - org.springframework.security - spring-security-config - ${spring-security.version} - - - org.springframework.security - spring-security-core - ${spring-security.version} - - - org.springframework.security - spring-security-crypto - ${spring-security.version} - - - org.springframework.security - spring-security-ldap - ${spring-security.version} - - - org.springframework.security - spring-security-openid - ${spring-security.version} - - - org.springframework.security - spring-security-remoting - ${spring-security.version} - - - org.springframework.security - spring-security-taglibs - ${spring-security.version} - - - org.springframework.security - spring-security-web + spring-security-bom ${spring-security.version} + import + pom org.springframework.security diff --git a/spring-boot-tools/spring-boot-dependency-tools/pom.xml b/spring-boot-tools/spring-boot-dependency-tools/pom.xml index 077ca030993..a2811972f85 100644 --- a/spring-boot-tools/spring-boot-dependency-tools/pom.xml +++ b/spring-boot-tools/spring-boot-dependency-tools/pom.xml @@ -3,8 +3,9 @@ 4.0.0 org.springframework.boot - spring-boot-tools + spring-boot-dependencies 1.1.0.BUILD-SNAPSHOT + ../../spring-boot-dependencies spring-boot-dependency-tools Spring Boot Dependency Tools @@ -18,6 +19,18 @@ ${basedir}/../.. ${project.build.directory}/generated-resources/org/springframework/boot/dependency/tools + + + junit + junit + test + + + org.hamcrest + hamcrest-library + test + + diff --git a/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PomManagedDependencies.java b/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PomManagedDependencies.java index 45d1ebe4e08..2027822a631 100644 --- a/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PomManagedDependencies.java +++ b/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PomManagedDependencies.java @@ -18,9 +18,7 @@ package org.springframework.boot.dependency.tools; import java.io.InputStream; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -32,7 +30,7 @@ import org.w3c.dom.NodeList; /** * {@link ManagedDependencies} implementation backed a maven POM. - * + * * @author Phillip Webb * @since 1.1.0 */ @@ -42,36 +40,13 @@ public class PomManagedDependencies extends AbstractManagedDependencies { * Create a new {@link PomManagedDependencies} instance. * @param effectivePomInputStream the effective POM containing resolved versions. The * input stream will be closed once content has been loaded. - * @param dependenciesInputStream and optional POM used to limit the dependencies. The - * input stream will be closed once content has been loaded. which will be added from - * the effective POM */ - public PomManagedDependencies(InputStream effectivePomInputStream, - InputStream dependenciesInputStream) { + public PomManagedDependencies(InputStream effectivePomInputStream) { try { Document effectivePom = readDocument(effectivePomInputStream); - Document dependenciesPom = readDocument(dependenciesInputStream); - if (dependenciesPom == null) { - // No dependencies POM, add all items - for (Dependency dependency : readDependencies(effectivePom)) { - add(new ArtifactAndGroupId(dependency), dependency); - } - } - else { - // Only add items that are also in the dependencies POM - Map all = new HashMap(); - for (Dependency dependency : readDependencies(effectivePom)) { - all.put(new ArtifactAndGroupId(dependency), dependency); - } - for (Dependency dependency : readDependencies(dependenciesPom)) { - ArtifactAndGroupId artifactAndGroupId = new ArtifactAndGroupId( - dependency); - Dependency effectiveDependency = all.get(artifactAndGroupId); - if (effectiveDependency != null) { - add(artifactAndGroupId, effectiveDependency); - } - } + for (Dependency dependency : readDependencies(effectivePom)) { + add(new ArtifactAndGroupId(dependency), dependency); } } catch (Exception ex) { diff --git a/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PropertiesFileManagedDependencies.java b/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PropertiesFileManagedDependencies.java index 7369f639ca2..4ba46b6765b 100644 --- a/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PropertiesFileManagedDependencies.java +++ b/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PropertiesFileManagedDependencies.java @@ -24,9 +24,9 @@ import java.util.TreeMap; /** * {@link ManagedDependencies} backed by an external properties file (of the form created - * by the Spring IO platform). The property key should be the groupID and versionId (in - * the form {@literal group:version}) and the value should be the version. - * + * by the Spring IO platform). The property key should be the groupId and artifactId (in + * the form {@literal groupId:artifactId}) and the value should be the version. + * * @author Phillip Webb * @since 1.1.0 */ diff --git a/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/VersionManagedDependencies.java b/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/VersionManagedDependencies.java index 4128b8b4f2a..7bb4ed3f256 100644 --- a/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/VersionManagedDependencies.java +++ b/spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/VersionManagedDependencies.java @@ -24,7 +24,7 @@ import java.util.Collections; * {@link ManagedDependencies} used by various spring boot tools. Provides programmatic * access to 'spring-boot-dependencies' and can also support user defined version managed * dependencies. - * + * * @author Phillip Webb * @since 1.1.0 */ @@ -70,7 +70,7 @@ public class VersionManagedDependencies extends AbstractManagedDependencies { private static ManagedDependencies getSpringBootDependencies() { if (springBootDependencies == null) { springBootDependencies = new PomManagedDependencies( - getResource("effective-pom.xml"), getResource("dependencies-pom.xml")); + getResource("effective-pom.xml")); } return springBootDependencies; } diff --git a/spring-boot-tools/spring-boot-dependency-tools/src/test/java/org/springframework/boot/dependency/tools/PomManagedDependenciesTests.java b/spring-boot-tools/spring-boot-dependency-tools/src/test/java/org/springframework/boot/dependency/tools/PomManagedDependenciesTests.java index 09f1f00985d..4af1567345c 100644 --- a/spring-boot-tools/spring-boot-dependency-tools/src/test/java/org/springframework/boot/dependency/tools/PomManagedDependenciesTests.java +++ b/spring-boot-tools/spring-boot-dependency-tools/src/test/java/org/springframework/boot/dependency/tools/PomManagedDependenciesTests.java @@ -29,7 +29,7 @@ import static org.junit.Assert.assertThat; /** * Tests for {@link PomManagedDependencies}. - * + * * @author Phillip Webb */ public class PomManagedDependenciesTests { @@ -39,8 +39,7 @@ public class PomManagedDependenciesTests { @Before public void setup() { InputStream x = getResource("test-effective-pom.xml"); - InputStream y = getResource("test-dependencies-pom.xml"); - this.dependencies = new PomManagedDependencies(x, y); + this.dependencies = new PomManagedDependencies(x); } private InputStream getResource(String name) { @@ -76,11 +75,6 @@ public class PomManagedDependenciesTests { assertThat(this.dependencies.find("org.sample", "missing"), nullValue()); } - @Test - public void findByArtifactAndGroupIdOnlyInEffectivePom() throws Exception { - assertThat(this.dependencies.find("org.extra", "extra01"), nullValue()); - } - @Test public void findByArtifactId() throws Exception { assertThat(this.dependencies.find("sample02").toString(), diff --git a/spring-boot-tools/spring-boot-dependency-tools/src/test/resources/org/springframework/boot/dependency/tools/test-dependencies-pom.xml b/spring-boot-tools/spring-boot-dependency-tools/src/test/resources/org/springframework/boot/dependency/tools/test-dependencies-pom.xml deleted file mode 100644 index d41d9ce8dec..00000000000 --- a/spring-boot-tools/spring-boot-dependency-tools/src/test/resources/org/springframework/boot/dependency/tools/test-dependencies-pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - 4.0.0 - 1.0.0.BUILD-SNAPSHOT - - 1.0.0 - - - 3.0.0 - - - - - org.sample - sample01 - ${sample.version} - - - org.exclude - exclude01 - - - - - org.sample - sample02 - ${sample.version} - - - org.springframework.boot - spring-boot - 1.0.0.BUILD-SNAPSHOT - - - - diff --git a/spring-boot-tools/spring-boot-dependency-tools/src/test/resources/org/springframework/boot/dependency/tools/test-effective-pom.xml b/spring-boot-tools/spring-boot-dependency-tools/src/test/resources/org/springframework/boot/dependency/tools/test-effective-pom.xml index 5cdad4fdbc7..0343fd20549 100644 --- a/spring-boot-tools/spring-boot-dependency-tools/src/test/resources/org/springframework/boot/dependency/tools/test-effective-pom.xml +++ b/spring-boot-tools/spring-boot-dependency-tools/src/test/resources/org/springframework/boot/dependency/tools/test-effective-pom.xml @@ -29,11 +29,6 @@ spring-boot 1.0.0.BUILD-SNAPSHOT - - org.extra - extra01 - 2.0.0 -