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
This commit is contained in:
Phillip Webb 2014-06-07 23:05:51 -07:00
parent 9b982dabdb
commit 28090e8a5f
5 changed files with 265 additions and 0 deletions

View File

@ -162,6 +162,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>1.1.0.BUILD-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -292,6 +298,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>1.1.0.BUILD-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -20,6 +20,7 @@
<main.basedir>${basedir}/..</main.basedir>
</properties>
<modules>
<!-- If you add a starter remember to also add a dependency in spring-boot-versions -->
<module>spring-boot-starter</module>
<module>spring-boot-starter-amqp</module>
<module>spring-boot-starter-aop</module>

View File

@ -28,6 +28,7 @@
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<executions>
<execution>
@ -42,6 +43,49 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>execute</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<scripts>
<script>file:///${project.basedir}/src/main/groovy/generateDependencyTreePom.groovy</script>
</scripts>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<executions>
<execution>
<id>generate-dependency-tree</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<cloneProjectsTo>${project.build.directory}/invoker</cloneProjectsTo>
<settingsFile>src/dependency-tree/settings.xml</settingsFile>
<streamLogs>true</streamLogs>
<pom>${basedir}/src/dependency-tree/pom.xml</pom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
@ -89,6 +133,10 @@
<file>${project.build.directory}/effective-pom/spring-boot-versions.xml</file>
<type>effective-pom</type>
</artifact>
<artifact>
<file>${project.build.directory}/dependency-tree/dependency-tree.txt </file>
<type>dependency-tree</type>
</artifact>
</artifacts>
</configuration>
</execution>
@ -96,4 +144,134 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-gemfire</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-solr</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-groovy-templates</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hornetq</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mobile</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-remote-shell</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-social-facebook</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-social-linkedin</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-social-twitter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-velocity</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-versions</artifactId>
<version>@project.version@</version>
<relativePath>../../target/dependency-tree</relativePath>
</parent>
<artifactId>spring-boot-versions-dependency-tree</artifactId>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>write-dependencies-tree</id>
<phase>generate-resources</phase>
<goals>
<goal>tree</goal>
</goals>
<configuration>
<outputFile>@project.build.directory@/dependency-tree/dependency-tree.txt</outputFile>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-ext</id>
<url>http://repo.spring.io/ext-release-local/</url>
</repository>
</repositories>
</project>

View File

@ -0,0 +1,34 @@
// Generate a POM from the effective-pom that can be used to build a complete dependency tree
import groovy.util.*
import groovy.xml.*
def effectivePom = new XmlSlurper().parse(
new File(project.build.directory, 'effective-pom/spring-boot-versions.xml'))
effectivePom.dependencyManagement.dependencies.dependency.findAll{ it.groupId != "org.springframework.boot" }.each {
effectivePom.dependencies.appendNode( it )
}
// effectivePom.appendNode(effectivePom.dependencyManagement.dependencies)
effectivePom.parent.replaceNode {}
effectivePom.dependencyManagement.replaceNode {}
effectivePom.build.replaceNode {}
effectivePom.properties.replaceNode {}
effectivePom.repositories.replaceNode {}
effectivePom.pluginRepositories.replaceNode {}
effectivePom.reporting.replaceNode {}
out = new StreamingMarkupBuilder()
String xmlResult = out.bind {
mkp.declareNamespace("": "http://maven.apache.org/POM/4.0.0")
mkp.yield effectivePom
}
def outputDir = new File(project.build.directory, 'dependency-tree');
outputDir.mkdirs();
XmlUtil.serialize(xmlResult, new FileWriter(new File(outputDir, 'pom.xml')))