Skip to content

Commit 28090e8

Browse files
author
Phillip Webb
committed
Generate and attach dependency-tree
Update spring-boot-versions to generate a dependency-tree file and attach it as an artifact. The file is generated by creating a temporary POM and calling the invoker plugin. The spring-boot-versions POM now depends on all spring-boot-starter-* POMs to ensure that they have been installed before the dependency tree is processes. See gh-1047
1 parent 9b982da commit 28090e8

File tree

5 files changed

+265
-0
lines changed

5 files changed

+265
-0
lines changed

spring-boot-dependencies/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@
162162
<groupId>org.springframework.boot</groupId>
163163
<artifactId>spring-boot-starter</artifactId>
164164
<version>1.1.0.BUILD-SNAPSHOT</version>
165+
<exclusions>
166+
<exclusion>
167+
<groupId>commons-logging</groupId>
168+
<artifactId>commons-logging</artifactId>
169+
</exclusion>
170+
</exclusions>
165171
</dependency>
166172
<dependency>
167173
<groupId>org.springframework.boot</groupId>
@@ -292,6 +298,12 @@
292298
<groupId>org.springframework.boot</groupId>
293299
<artifactId>spring-boot-starter-test</artifactId>
294300
<version>1.1.0.BUILD-SNAPSHOT</version>
301+
<exclusions>
302+
<exclusion>
303+
<groupId>commons-logging</groupId>
304+
<artifactId>commons-logging</artifactId>
305+
</exclusion>
306+
</exclusions>
295307
</dependency>
296308
<dependency>
297309
<groupId>org.springframework.boot</groupId>

spring-boot-starters/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<main.basedir>${basedir}/..</main.basedir>
2121
</properties>
2222
<modules>
23+
<!-- If you add a starter remember to also add a dependency in spring-boot-versions -->
2324
<module>spring-boot-starter</module>
2425
<module>spring-boot-starter-amqp</module>
2526
<module>spring-boot-starter-aop</module>

spring-boot-versions/pom.xml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
</resources>
2929
<plugins>
3030
<plugin>
31+
<groupId>org.apache.maven.plugins</groupId>
3132
<artifactId>maven-help-plugin</artifactId>
3233
<executions>
3334
<execution>
@@ -42,6 +43,49 @@
4243
</execution>
4344
</executions>
4445
</plugin>
46+
<plugin>
47+
<groupId>org.codehaus.gmavenplus</groupId>
48+
<artifactId>gmavenplus-plugin</artifactId>
49+
<executions>
50+
<execution>
51+
<goals>
52+
<goal>execute</goal>
53+
</goals>
54+
<phase>generate-resources</phase>
55+
</execution>
56+
</executions>
57+
<configuration>
58+
<scripts>
59+
<script>file:///${project.basedir}/src/main/groovy/generateDependencyTreePom.groovy</script>
60+
</scripts>
61+
</configuration>
62+
<dependencies>
63+
<dependency>
64+
<groupId>org.codehaus.groovy</groupId>
65+
<artifactId>groovy-all</artifactId>
66+
<version>${groovy.version}</version>
67+
</dependency>
68+
</dependencies>
69+
</plugin>
70+
<plugin>
71+
<groupId>org.apache.maven.plugins</groupId>
72+
<artifactId>maven-invoker-plugin</artifactId>
73+
<executions>
74+
<execution>
75+
<id>generate-dependency-tree</id>
76+
<phase>generate-resources</phase>
77+
<goals>
78+
<goal>run</goal>
79+
</goals>
80+
<configuration>
81+
<cloneProjectsTo>${project.build.directory}/invoker</cloneProjectsTo>
82+
<settingsFile>src/dependency-tree/settings.xml</settingsFile>
83+
<streamLogs>true</streamLogs>
84+
<pom>${basedir}/src/dependency-tree/pom.xml</pom>
85+
</configuration>
86+
</execution>
87+
</executions>
88+
</plugin>
4589
<plugin>
4690
<groupId>org.codehaus.mojo</groupId>
4791
<artifactId>xml-maven-plugin</artifactId>
@@ -89,11 +133,145 @@
89133
<file>${project.build.directory}/effective-pom/spring-boot-versions.xml</file>
90134
<type>effective-pom</type>
91135
</artifact>
136+
<artifact>
137+
<file>${project.build.directory}/dependency-tree/dependency-tree.txt </file>
138+
<type>dependency-tree</type>
139+
</artifact>
92140
</artifacts>
93141
</configuration>
94142
</execution>
95143
</executions>
96144
</plugin>
97145
</plugins>
98146
</build>
147+
<dependencies>
148+
<dependency>
149+
<groupId>org.springframework.boot</groupId>
150+
<artifactId>spring-boot-starter</artifactId>
151+
</dependency>
152+
<dependency>
153+
<groupId>org.springframework.boot</groupId>
154+
<artifactId>spring-boot-starter-actuator</artifactId>
155+
</dependency>
156+
<dependency>
157+
<groupId>org.springframework.boot</groupId>
158+
<artifactId>spring-boot-starter-amqp</artifactId>
159+
</dependency>
160+
<dependency>
161+
<groupId>org.springframework.boot</groupId>
162+
<artifactId>spring-boot-starter-aop</artifactId>
163+
</dependency>
164+
<dependency>
165+
<groupId>org.springframework.boot</groupId>
166+
<artifactId>spring-boot-starter-batch</artifactId>
167+
</dependency>
168+
<dependency>
169+
<groupId>org.springframework.boot</groupId>
170+
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
171+
</dependency>
172+
<dependency>
173+
<groupId>org.springframework.boot</groupId>
174+
<artifactId>spring-boot-starter-data-gemfire</artifactId>
175+
</dependency>
176+
<dependency>
177+
<groupId>org.springframework.boot</groupId>
178+
<artifactId>spring-boot-starter-data-jpa</artifactId>
179+
</dependency>
180+
<dependency>
181+
<groupId>org.springframework.boot</groupId>
182+
<artifactId>spring-boot-starter-data-mongodb</artifactId>
183+
</dependency>
184+
<dependency>
185+
<groupId>org.springframework.boot</groupId>
186+
<artifactId>spring-boot-starter-data-rest</artifactId>
187+
</dependency>
188+
<dependency>
189+
<groupId>org.springframework.boot</groupId>
190+
<artifactId>spring-boot-starter-data-solr</artifactId>
191+
</dependency>
192+
<dependency>
193+
<groupId>org.springframework.boot</groupId>
194+
<artifactId>spring-boot-starter-freemarker</artifactId>
195+
</dependency>
196+
<dependency>
197+
<groupId>org.springframework.boot</groupId>
198+
<artifactId>spring-boot-starter-groovy-templates</artifactId>
199+
</dependency>
200+
<dependency>
201+
<groupId>org.springframework.boot</groupId>
202+
<artifactId>spring-boot-starter-hornetq</artifactId>
203+
</dependency>
204+
<dependency>
205+
<groupId>org.springframework.boot</groupId>
206+
<artifactId>spring-boot-starter-integration</artifactId>
207+
</dependency>
208+
<dependency>
209+
<groupId>org.springframework.boot</groupId>
210+
<artifactId>spring-boot-starter-jdbc</artifactId>
211+
</dependency>
212+
<dependency>
213+
<groupId>org.springframework.boot</groupId>
214+
<artifactId>spring-boot-starter-jetty</artifactId>
215+
</dependency>
216+
<dependency>
217+
<groupId>org.springframework.boot</groupId>
218+
<artifactId>spring-boot-starter-log4j</artifactId>
219+
</dependency>
220+
<dependency>
221+
<groupId>org.springframework.boot</groupId>
222+
<artifactId>spring-boot-starter-logging</artifactId>
223+
</dependency>
224+
<dependency>
225+
<groupId>org.springframework.boot</groupId>
226+
<artifactId>spring-boot-starter-mobile</artifactId>
227+
</dependency>
228+
<dependency>
229+
<groupId>org.springframework.boot</groupId>
230+
<artifactId>spring-boot-starter-redis</artifactId>
231+
</dependency>
232+
<dependency>
233+
<groupId>org.springframework.boot</groupId>
234+
<artifactId>spring-boot-starter-remote-shell</artifactId>
235+
</dependency>
236+
<dependency>
237+
<groupId>org.springframework.boot</groupId>
238+
<artifactId>spring-boot-starter-security</artifactId>
239+
</dependency>
240+
<dependency>
241+
<groupId>org.springframework.boot</groupId>
242+
<artifactId>spring-boot-starter-social-facebook</artifactId>
243+
</dependency>
244+
<dependency>
245+
<groupId>org.springframework.boot</groupId>
246+
<artifactId>spring-boot-starter-social-linkedin</artifactId>
247+
</dependency>
248+
<dependency>
249+
<groupId>org.springframework.boot</groupId>
250+
<artifactId>spring-boot-starter-social-twitter</artifactId>
251+
</dependency>
252+
<dependency>
253+
<groupId>org.springframework.boot</groupId>
254+
<artifactId>spring-boot-starter-test</artifactId>
255+
</dependency>
256+
<dependency>
257+
<groupId>org.springframework.boot</groupId>
258+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
259+
</dependency>
260+
<dependency>
261+
<groupId>org.springframework.boot</groupId>
262+
<artifactId>spring-boot-starter-tomcat</artifactId>
263+
</dependency>
264+
<dependency>
265+
<groupId>org.springframework.boot</groupId>
266+
<artifactId>spring-boot-starter-velocity</artifactId>
267+
</dependency>
268+
<dependency>
269+
<groupId>org.springframework.boot</groupId>
270+
<artifactId>spring-boot-starter-web</artifactId>
271+
</dependency>
272+
<dependency>
273+
<groupId>org.springframework.boot</groupId>
274+
<artifactId>spring-boot-starter-websocket</artifactId>
275+
</dependency>
276+
</dependencies>
99277
</project>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-versions</artifactId>
8+
<version>@project.version@</version>
9+
<relativePath>../../target/dependency-tree</relativePath>
10+
</parent>
11+
<artifactId>spring-boot-versions-dependency-tree</artifactId>
12+
<packaging>pom</packaging>
13+
<build>
14+
<plugins>
15+
<plugin>
16+
<groupId>org.apache.maven.plugins</groupId>
17+
<artifactId>maven-dependency-plugin</artifactId>
18+
<executions>
19+
<execution>
20+
<id>write-dependencies-tree</id>
21+
<phase>generate-resources</phase>
22+
<goals>
23+
<goal>tree</goal>
24+
</goals>
25+
<configuration>
26+
<outputFile>@project.build.directory@/dependency-tree/dependency-tree.txt</outputFile>
27+
<verbose>true</verbose>
28+
</configuration>
29+
</execution>
30+
</executions>
31+
</plugin>
32+
</plugins>
33+
</build>
34+
<repositories>
35+
<repository>
36+
<id>spring-ext</id>
37+
<url>http://repo.spring.io/ext-release-local/</url>
38+
</repository>
39+
</repositories>
40+
</project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Generate a POM from the effective-pom that can be used to build a complete dependency tree
2+
3+
import groovy.util.*
4+
import groovy.xml.*
5+
6+
def effectivePom = new XmlSlurper().parse(
7+
new File(project.build.directory, 'effective-pom/spring-boot-versions.xml'))
8+
9+
effectivePom.dependencyManagement.dependencies.dependency.findAll{ it.groupId != "org.springframework.boot" }.each {
10+
effectivePom.dependencies.appendNode( it )
11+
}
12+
13+
// effectivePom.appendNode(effectivePom.dependencyManagement.dependencies)
14+
effectivePom.parent.replaceNode {}
15+
effectivePom.dependencyManagement.replaceNode {}
16+
effectivePom.build.replaceNode {}
17+
effectivePom.properties.replaceNode {}
18+
effectivePom.repositories.replaceNode {}
19+
effectivePom.pluginRepositories.replaceNode {}
20+
effectivePom.reporting.replaceNode {}
21+
22+
out = new StreamingMarkupBuilder()
23+
String xmlResult = out.bind {
24+
mkp.declareNamespace("": "http://maven.apache.org/POM/4.0.0")
25+
mkp.yield effectivePom
26+
}
27+
28+
29+
def outputDir = new File(project.build.directory, 'dependency-tree');
30+
outputDir.mkdirs();
31+
XmlUtil.serialize(xmlResult, new FileWriter(new File(outputDir, 'pom.xml')))
32+
33+
34+

0 commit comments

Comments
 (0)