Skip to content

Commit 307fbba

Browse files
committed
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 spring-projects#825 Fixes spring-projects#838
1 parent b94e8f5 commit 307fbba

File tree

8 files changed

+28
-135
lines changed

8 files changed

+28
-135
lines changed

spring-boot-dependencies/pom.xml

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,58 +1015,10 @@
10151015
</dependency>
10161016
<dependency>
10171017
<groupId>org.springframework.security</groupId>
1018-
<artifactId>spring-security-acl</artifactId>
1019-
<version>${spring-security.version}</version>
1020-
</dependency>
1021-
<dependency>
1022-
<groupId>org.springframework.security</groupId>
1023-
<artifactId>spring-security-aspects</artifactId>
1024-
<version>${spring-security.version}</version>
1025-
</dependency>
1026-
<dependency>
1027-
<groupId>org.springframework.security</groupId>
1028-
<artifactId>spring-security-cas</artifactId>
1029-
<version>${spring-security.version}</version>
1030-
</dependency>
1031-
<dependency>
1032-
<groupId>org.springframework.security</groupId>
1033-
<artifactId>spring-security-config</artifactId>
1034-
<version>${spring-security.version}</version>
1035-
</dependency>
1036-
<dependency>
1037-
<groupId>org.springframework.security</groupId>
1038-
<artifactId>spring-security-core</artifactId>
1039-
<version>${spring-security.version}</version>
1040-
</dependency>
1041-
<dependency>
1042-
<groupId>org.springframework.security</groupId>
1043-
<artifactId>spring-security-crypto</artifactId>
1044-
<version>${spring-security.version}</version>
1045-
</dependency>
1046-
<dependency>
1047-
<groupId>org.springframework.security</groupId>
1048-
<artifactId>spring-security-ldap</artifactId>
1049-
<version>${spring-security.version}</version>
1050-
</dependency>
1051-
<dependency>
1052-
<groupId>org.springframework.security</groupId>
1053-
<artifactId>spring-security-openid</artifactId>
1054-
<version>${spring-security.version}</version>
1055-
</dependency>
1056-
<dependency>
1057-
<groupId>org.springframework.security</groupId>
1058-
<artifactId>spring-security-remoting</artifactId>
1059-
<version>${spring-security.version}</version>
1060-
</dependency>
1061-
<dependency>
1062-
<groupId>org.springframework.security</groupId>
1063-
<artifactId>spring-security-taglibs</artifactId>
1064-
<version>${spring-security.version}</version>
1065-
</dependency>
1066-
<dependency>
1067-
<groupId>org.springframework.security</groupId>
1068-
<artifactId>spring-security-web</artifactId>
1018+
<artifactId>spring-security-bom</artifactId>
10691019
<version>${spring-security.version}</version>
1020+
<scope>import</scope>
1021+
<type>pom</type>
10701022
</dependency>
10711023
<dependency>
10721024
<groupId>org.springframework.security</groupId>

spring-boot-tools/spring-boot-dependency-tools/pom.xml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
<modelVersion>4.0.0</modelVersion>
44
<parent>
55
<groupId>org.springframework.boot</groupId>
6-
<artifactId>spring-boot-tools</artifactId>
6+
<artifactId>spring-boot-dependencies</artifactId>
77
<version>1.1.0.BUILD-SNAPSHOT</version>
8+
<relativePath>../../spring-boot-dependencies</relativePath>
89
</parent>
910
<artifactId>spring-boot-dependency-tools</artifactId>
1011
<name>Spring Boot Dependency Tools</name>
@@ -18,6 +19,18 @@
1819
<main.basedir>${basedir}/../..</main.basedir>
1920
<generated.pom.dir>${project.build.directory}/generated-resources/org/springframework/boot/dependency/tools</generated.pom.dir>
2021
</properties>
22+
<dependencies>
23+
<dependency>
24+
<groupId>junit</groupId>
25+
<artifactId>junit</artifactId>
26+
<scope>test</scope>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.hamcrest</groupId>
30+
<artifactId>hamcrest-library</artifactId>
31+
<scope>test</scope>
32+
</dependency>
33+
</dependencies>
2134
<build>
2235
<resources>
2336
<resource>

spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PomManagedDependencies.java

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
import java.io.InputStream;
2020
import java.util.ArrayList;
21-
import java.util.HashMap;
2221
import java.util.List;
23-
import java.util.Map;
2422

2523
import javax.xml.parsers.DocumentBuilder;
2624
import javax.xml.parsers.DocumentBuilderFactory;
@@ -32,7 +30,7 @@
3230

3331
/**
3432
* {@link ManagedDependencies} implementation backed a maven POM.
35-
*
33+
*
3634
* @author Phillip Webb
3735
* @since 1.1.0
3836
*/
@@ -42,36 +40,13 @@ public class PomManagedDependencies extends AbstractManagedDependencies {
4240
* Create a new {@link PomManagedDependencies} instance.
4341
* @param effectivePomInputStream the effective POM containing resolved versions. The
4442
* input stream will be closed once content has been loaded.
45-
* @param dependenciesInputStream and optional POM used to limit the dependencies. The
46-
* input stream will be closed once content has been loaded. which will be added from
47-
* the effective POM
4843
*/
49-
public PomManagedDependencies(InputStream effectivePomInputStream,
50-
InputStream dependenciesInputStream) {
44+
public PomManagedDependencies(InputStream effectivePomInputStream) {
5145
try {
5246
Document effectivePom = readDocument(effectivePomInputStream);
53-
Document dependenciesPom = readDocument(dependenciesInputStream);
5447

55-
if (dependenciesPom == null) {
56-
// No dependencies POM, add all items
57-
for (Dependency dependency : readDependencies(effectivePom)) {
58-
add(new ArtifactAndGroupId(dependency), dependency);
59-
}
60-
}
61-
else {
62-
// Only add items that are also in the dependencies POM
63-
Map<ArtifactAndGroupId, Dependency> all = new HashMap<ArtifactAndGroupId, Dependency>();
64-
for (Dependency dependency : readDependencies(effectivePom)) {
65-
all.put(new ArtifactAndGroupId(dependency), dependency);
66-
}
67-
for (Dependency dependency : readDependencies(dependenciesPom)) {
68-
ArtifactAndGroupId artifactAndGroupId = new ArtifactAndGroupId(
69-
dependency);
70-
Dependency effectiveDependency = all.get(artifactAndGroupId);
71-
if (effectiveDependency != null) {
72-
add(artifactAndGroupId, effectiveDependency);
73-
}
74-
}
48+
for (Dependency dependency : readDependencies(effectivePom)) {
49+
add(new ArtifactAndGroupId(dependency), dependency);
7550
}
7651
}
7752
catch (Exception ex) {

spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/PropertiesFileManagedDependencies.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

2525
/**
2626
* {@link ManagedDependencies} backed by an external properties file (of the form created
27-
* by the Spring IO platform). The property key should be the groupID and versionId (in
28-
* the form {@literal group:version}) and the value should be the version.
29-
*
27+
* by the Spring IO platform). The property key should be the groupId and artifactId (in
28+
* the form {@literal groupId:artifactId}) and the value should be the version.
29+
*
3030
* @author Phillip Webb
3131
* @since 1.1.0
3232
*/

spring-boot-tools/spring-boot-dependency-tools/src/main/java/org/springframework/boot/dependency/tools/VersionManagedDependencies.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* {@link ManagedDependencies} used by various spring boot tools. Provides programmatic
2525
* access to 'spring-boot-dependencies' and can also support user defined version managed
2626
* dependencies.
27-
*
27+
*
2828
* @author Phillip Webb
2929
* @since 1.1.0
3030
*/
@@ -70,7 +70,7 @@ private void addAll(ManagedDependencies dependencies) {
7070
private static ManagedDependencies getSpringBootDependencies() {
7171
if (springBootDependencies == null) {
7272
springBootDependencies = new PomManagedDependencies(
73-
getResource("effective-pom.xml"), getResource("dependencies-pom.xml"));
73+
getResource("effective-pom.xml"));
7474
}
7575
return springBootDependencies;
7676
}

spring-boot-tools/spring-boot-dependency-tools/src/test/java/org/springframework/boot/dependency/tools/PomManagedDependenciesTests.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
/**
3131
* Tests for {@link PomManagedDependencies}.
32-
*
32+
*
3333
* @author Phillip Webb
3434
*/
3535
public class PomManagedDependenciesTests {
@@ -39,8 +39,7 @@ public class PomManagedDependenciesTests {
3939
@Before
4040
public void setup() {
4141
InputStream x = getResource("test-effective-pom.xml");
42-
InputStream y = getResource("test-dependencies-pom.xml");
43-
this.dependencies = new PomManagedDependencies(x, y);
42+
this.dependencies = new PomManagedDependencies(x);
4443
}
4544

4645
private InputStream getResource(String name) {
@@ -76,11 +75,6 @@ public void findByArtifactAndGroupIdMissing() throws Exception {
7675
assertThat(this.dependencies.find("org.sample", "missing"), nullValue());
7776
}
7877

79-
@Test
80-
public void findByArtifactAndGroupIdOnlyInEffectivePom() throws Exception {
81-
assertThat(this.dependencies.find("org.extra", "extra01"), nullValue());
82-
}
83-
8478
@Test
8579
public void findByArtifactId() throws Exception {
8680
assertThat(this.dependencies.find("sample02").toString(),

spring-boot-tools/spring-boot-dependency-tools/src/test/resources/org/springframework/boot/dependency/tools/test-dependencies-pom.xml

Lines changed: 0 additions & 36 deletions
This file was deleted.

spring-boot-tools/spring-boot-dependency-tools/src/test/resources/org/springframework/boot/dependency/tools/test-effective-pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@
2929
<artifactId>spring-boot</artifactId>
3030
<version>1.0.0.BUILD-SNAPSHOT</version>
3131
</dependency>
32-
<dependency>
33-
<groupId>org.extra</groupId>
34-
<artifactId>extra01</artifactId>
35-
<version>2.0.0</version>
36-
</dependency>
3732
</dependencies>
3833
</dependencyManagement>
3934
</project>

0 commit comments

Comments
 (0)