Replace basic Gradle dependency management with use of separate plugin

This commit replaces Spring Boot's basic dependency management support
with separate dependency management plugin. This has a number of
benefits including:

1. A Maven bom can be used rather than a custom properties file
2. Dependency management is applied transitively rather than only to
   direct dependencies
3. Exclusions are applied as they would be in Maven
4. Gradle-generated poms are automatically configured with the
   appropriate dependency management

Closes gh-2133
This commit is contained in:
Andy Wilkinson 2015-03-18 17:08:07 +00:00
parent cb067ee00c
commit 2c3c62d71c
59 changed files with 132 additions and 1090 deletions

View File

@ -64,7 +64,7 @@
<freemarker.version>2.3.22</freemarker.version>
<gemfire.version>7.0.2</gemfire.version>
<glassfish-el.version>3.0.0</glassfish-el.version>
<gradle.version>1.6</gradle.version>
<gradle.version>1.12</gradle.version>
<groovy.version>2.4.1</groovy.version>
<gson.version>2.3.1</gson.version>
<h2.version>1.4.185</h2.version>

View File

@ -165,8 +165,8 @@ Advanced configuration options and examples are available in the
[[build-tool-plugins-gradle-plugin]]
== Spring Boot Gradle plugin
The Spring Boot Gradle Plugin provides Spring Boot support in Gradle, allowing you to
package executable jar or war archives, run Spring Boot applications and omit version
information from your `build.gradle` file for "`blessed`" dependencies.
package executable jar or war archives, run Spring Boot applications and use the
dependency management provided by `spring-boot-dependencies`.
@ -201,12 +201,15 @@ If you are using a milestone or snapshot release you will also need to add appro
[[build-tool-plugins-gradle-dependencies-without-versions]]
=== Declaring dependencies without versions
The `spring-boot` plugin will register a custom Gradle `ResolutionStrategy` with your
build that allows you to omit version numbers when declaring dependencies to "`blessed`"
artifacts. To make use of this functionality, simply declare dependencies in the usual way,
but leave the version number empty:
[[build-tool-plugins-gradle-dependency-management]]
=== Dependency management
The `spring-boot` plugin automatically applies the
{dependency-management-plugin}/[Dependency Management Plugin] and configures in to import
the `spring-boot-starter-parent` bom. This provides a similar dependency management
experience to the one that is enjoyed by Maven users. For example, it allows you to omit
version numbers when declaring dependencies that are managed in the bom. To make use of
this functionality, simply declare dependencies in the usual way, but leave the version
number empty:
[source,groovy,indent=0,subs="verbatim,attributes"]
----
@ -218,12 +221,12 @@ but leave the version number empty:
----
NOTE: The version of the `spring-boot` gradle plugin that you declare determines the
actual versions of the "`blessed`" dependencies (this ensures that builds are always
repeatable). You should always set the version of the `spring-boot` gradle plugin to the
actual Spring Boot version that you wish to use. Details of the versions that are
provided can be found in the <<appendix-dependency-versions, appendix>>.
version of the `spring-boot-starter-parent` bom that is imported (this ensures that builds
are always repeatable). You should always set the version of the `spring-boot` gradle
plugin to the actual Spring Boot version that you wish to use. Details of the versions
that are provided can be found in the <<appendix-dependency-versions, appendix>>.
The `spring-boot` plugin will only supply a version where one is not specified. To
The dependency management plugin will only supply a version where one is not specified. To
use a version of an artifact that differs from the one that the plugin would provide,
simply specify the version when you declare the dependency as you usually would. For
example:
@ -235,81 +238,8 @@ example:
}
----
[[build-tool-plugins-gradle-custom-version-management]]
==== Custom version management
If is possible to customize the versions used by the `ResolutionStrategy` if you need
to deviate from Spring Boot's "`blessed`" dependencies. Alternative version metadata
is consulted using the `versionManagement` configuration. For example:
[source,groovy,indent=0,subs="verbatim,attributes"]
----
dependencies {
versionManagement("com.mycorp:mycorp-versions:1.0.0.RELEASE@properties")
compile("org.springframework.data:spring-data-hadoop")
}
----
Version information needs to be published to a repository as a `.properties` file. For
the above example `mycorp-versions.properties` file might contain the following:
[source,properties,indent=0,subs="verbatim,attributes"]
----
org.springframework.data\:spring-data-hadoop=2.0.0.RELEASE
----
The properties file takes precedence over Spring Boot's defaults, and can be used
to override version numbers if necessary.
[[build-tool-plugins-gradle-exclude-rules]]
=== Default exclude rules
Gradle handles "`exclude rules`" in a slightly different way to Maven which can cause
unexpected results when using the starter POMs. Specifically, exclusions declared on
a dependency will not be applied when the dependency can be reached through a different
path. For example, if a starter POM declares the following:
[source,xml,indent=0,subs="verbatim,attributes"]
----
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.0.5.RELEASE</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.0.5.RELEASE</version>
</dependency>
</dependencies>
----
The `commons-logging` jar will *not* be excluded by Gradle because it is pulled in
transitively via `spring-context` (`spring-context` -> `spring-core` -> `commons-logging`)
which does not have an `exclusion` element.
To ensure that correct exclusions are actually applied, the Spring Boot Gradle plugin will
automatically add exclusion rules. All exclusions defined in the
`spring-boot-dependencies` POM and implicit rules for the "`starter`" POMs will be added.
If you don't want exclusion rules automatically applied you can use the following
configuration:
[source,groovy,indent=0,subs="verbatim,attributes"]
----
springBoot {
applyExcludeRules=false
}
----
To learn more about the capabilities of the Dependency Management Plugin, please refer to
its {dependency-management-plugin-documentation}[documentation].

View File

@ -283,8 +283,7 @@ in your `application.properties`, e.g.
There's a blog on https://www.openshift.com/blogs/run-gradle-builds-on-openshift[running
Gradle in Openshift] on their website that will get you started with a gradle build to
run the app. A http://issues.gradle.org/browse/GRADLE-2871[bug in Gradle] currently
prevents you from using Gradle newer than 1.6.
run the app.

View File

@ -702,21 +702,11 @@ property, e.g. for a simple webapp or service:
==== Use Tomcat 7 with Gradle
[[howto-use-tomcat-7-gradle]]
You can use a resolution strategy to change the versions of the Tomcat dependencies,
e.g. for a simple webapp or service:
You can change the Tomcat version by setting the `tomcat.version` property:
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
----
configurations.all {
resolutionStrategy {
eachDependency {
if (it.requested.group == 'org.apache.tomcat.embed') {
it.useVersion '7.0.59'
}
}
}
}
ext['tomcat.version'] = '7.0.59'
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
}
@ -775,21 +765,12 @@ webapp or service:
[[howto-use-jetty-8-gradle]]
==== Use Jetty 8 with Gradle
You can use a resolution strategy to change the version of the Jetty dependencies, e.g.
for a simple webapp or service:
You can set the `jetty.version` property and exclude the WebSocket dependency, e.g. for a
simple webapp or service:
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
----
configurations.all {
resolutionStrategy {
eachDependency {
if (it.requested.group == 'org.eclipse.jetty') {
it.useVersion '8.1.15.v20140411'
}
}
}
}
ext['jetty.version'] = '8.1.15.v20140411'
dependencies {
compile ('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'

View File

@ -27,6 +27,8 @@ Phillip Webb; Dave Syer; Josh Long; Stéphane Nicoll; Rob Winch; Andy Wilkinson;
:dc-spring-boot: {dc-root}/org/springframework/boot
:dc-spring-boot-autoconfigure: {dc-root}/org/springframework/boot/autoconfigure
:dc-spring-boot-actuator: {dc-root}/org/springframework/boot/actuate
:dependency-management-plugin: https://github.com/spring-gradle-plugins/dependency-management-plugin
:dependency-management-plugin-documentation: {dependency-management-plugin}/blob/master/README.md
:spring-boot-maven-plugin-site: http://docs.spring.io/spring-boot/docs/{spring-boot-docs-version}/maven-plugin
:spring-reference: http://docs.spring.io/spring/docs/{spring-docs-version}/spring-framework-reference/htmlsingle
:spring-security-reference: http://docs.spring.io/spring-security/site/docs/{spring-security-docs-version}/reference/htmlsingle

View File

@ -153,11 +153,12 @@ Maven, there is no "`super parent`" to import to share some configuration.
}
----
The <<build-tool-plugins.adoc#build-tool-plugins-gradle-plugin, `spring-boot-gradle-plugin`>>
is also available and provides tasks to create executable jars and run projects from
source. It also adds a `ResolutionStrategy` that enables you to
<<build-tool-plugins-gradle-dependencies-without-versions, omit the version number
for "`blessed`" dependencies>>:
The <<build-tool-plugins.adoc#build-tool-plugins-gradle-plugin,
`spring-boot-gradle-plugin`>> is also available and provides tasks to create executable
jars and run projects from source. It also provides
<<build-tool-plugins-gradle-dependency-management, dependency management>> that, among
other capabilities, allows you to omit the version number for any dependencies that are
managed by Spring Boot:
[source,groovy,indent=0,subs="attributes"]
----

View File

@ -1,55 +0,0 @@
/*
* 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.gradle;
import java.io.IOException;
import org.gradle.tooling.ProjectConnection;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.boot.dependency.tools.ManagedDependencies;
/**
* Tests for using the Gradle plugin's support for custom version management
*
* @author Andy Wilkinson
*/
public class CustomVersionManagementTests {
private static final String BOOT_VERSION = ManagedDependencies.get()
.find("spring-boot").getVersion();
private static ProjectConnection project;
@BeforeClass
public static void createProject() throws IOException {
project = new ProjectCreator().createProject("custom-version-management");
}
@Test
public void exclusionsAreStillInPlace() {
project.newBuild().forTasks("checkExclusions")
.withArguments("-PbootVersion=" + BOOT_VERSION).run();
}
@Test
public void customSpringVersionIsUsed() {
project.newBuild().forTasks("checkSpringVersion")
.withArguments("-PbootVersion=" + BOOT_VERSION).run();
}
}

View File

@ -34,24 +34,17 @@ public class InstallTests {
@Test
public void cleanInstall() throws Exception {
project = new ProjectCreator().createProject("installer");
project.newBuild().forTasks("install")
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
}
@Test
public void cleanInstallVersionManagement() throws Exception {
project = new ProjectCreator().createProject("installer-io");
project.newBuild().forTasks("install")
this.project = new ProjectCreator().createProject("installer");
this.project.newBuild().forTasks("install")
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
}
@Test
public void cleanInstallApp() throws Exception {
project = new ProjectCreator().createProject("install-app");
this.project = new ProjectCreator().createProject("install-app");
// "install" from the application plugin was renamed "installApp" in Gradle
// 1.0
project.newBuild().forTasks("installApp")
this.project.newBuild().forTasks("installApp")
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace", "--info")
.run();
}

View File

@ -60,21 +60,6 @@ public class SpringLoadedTests {
"-javaagent:.*springloaded-" + SPRING_LOADED_VERSION + ".jar", output);
}
@Test
public void springLoadedCanBeUsedWithGradle16() throws IOException {
ProjectConnection project = new ProjectCreator("1.6")
.createProject("spring-loaded-old-gradle");
project.newBuild()
.forTasks("bootRun")
.withArguments("-PbootVersion=" + BOOT_VERSION,
"-PspringLoadedVersion=" + SPRING_LOADED_VERSION, "--stacktrace")
.run();
List<String> output = getOutput();
assertOutputMatches(
"-javaagent:.*springloaded-" + SPRING_LOADED_VERSION + ".jar", output);
}
private List<String> getOutput() throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(new File(
"target/spring-loaded-jvm-args/build/output.txt")));

View File

@ -10,6 +10,10 @@ buildscript {
apply plugin: 'java'
apply plugin: 'spring-boot'
repositories {
mavenLocal()
}
bootRun {
addResources = Boolean.valueOf(project.addResources)
}

View File

@ -1,63 +0,0 @@
import org.gradle.api.artifacts.result.UnresolvedDependencyResult;
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
}
}
repositories {
mavenLocal()
mavenCentral()
}
configurations {
exclusions
springVersion
}
apply plugin: 'spring-boot'
dependencies {
exclusions "org.springframework.boot:spring-boot-starter"
springVersion "org.springframework:spring-core"
versionManagement files('../../src/test/resources/custom-versions.properties')
}
task checkExclusions {
doFirst {
def commonsLogging = getResolvedDependencies(configurations.exclusions)
.find { it.selected.id.group == 'commons-logging' }
if (commonsLogging) {
throw new GradleException("commong-logging is a transitive dependency")
}
}
}
task checkSpringVersion {
doFirst {
def springVersions = getResolvedDependencies(configurations.springVersion)
.findAll{it.selected.id.group == 'org.springframework'}
.collect {it.selected.id.version}
if (springVersions.size() != 1 || !springVersions.contains("4.0.3.RELEASE")) {
throw new GradleException("Spring version was not 4.0.3.RELEASE")
}
}
}
def getResolvedDependencies(def configuration) {
def allDependencies = configuration.incoming
.resolutionResult.allDependencies
.split { it instanceof UnresolvedDependencyResult }
def unresolved = allDependencies.first()
def resolved = allDependencies.last()
if (unresolved) {
throw new GradleException("Resolution failed: ${unresolved}")
}
resolved
}

View File

@ -1,2 +0,0 @@
org.springframework\:spring-core=4.0.3.RELEASE
org.springframework.boot\:spring-boot-starter=1.1.0.RELEASE

View File

@ -21,6 +21,7 @@ jar {
}
repositories {
mavenLocal()
flatDir( dirs:'lib' )
}

View File

@ -1,41 +0,0 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'spring-boot'
group = 'installer'
version = '0.0.0'
install {
repositories.mavenInstaller {
pom.project {
parent {
groupId 'org.springframework.boot'
artifactId 'spring-boot-starter-parent'
version "${project.bootVersion}"
}
}
}
}
jar {
baseName = 'installer'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
versionManagement 'io.spring.platform:platform-versions:1.0.0.RELEASE@properties'
compile "org.springframework.boot:spring-boot-starter"
}

View File

@ -17,6 +17,10 @@ subprojects {
apply plugin: 'spring-boot'
repositories {
mavenLocal()
}
springBoot {
mainClass = 'foo.bar.Baz'
}

View File

@ -9,6 +9,9 @@ buildscript {
project(':projectA') {
apply plugin: 'spring-boot'
repositories {
mavenLocal()
}
dependencies {
runtime project(':projectB')
}

View File

@ -46,6 +46,11 @@
<dependencies>
<!-- Additional Dependencies the consumers of spring-boot-dependencies
will generally not need -->
<dependency>
<groupId>io.spring.gradle</groupId>
<artifactId>dependency-management-plugin</artifactId>
<version>0.4.1.RELEASE</version>
</dependency>
<dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>

View File

@ -26,15 +26,5 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

View File

@ -22,24 +22,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>

View File

@ -26,16 +26,6 @@
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>

View File

@ -26,16 +26,6 @@
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>

View File

@ -22,20 +22,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>

View File

@ -26,28 +26,6 @@
<groupId>com.gemstone.gemfire</groupId>
<artifactId>gemfire</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-gemfire</artifactId>

View File

@ -26,16 +26,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
@ -54,10 +44,6 @@
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>

View File

@ -26,20 +26,6 @@
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>

View File

@ -34,20 +34,6 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-webmvc</artifactId>

View File

@ -32,20 +32,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-solr</artifactId>

View File

@ -30,16 +30,6 @@
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>

View File

@ -26,23 +26,9 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-templates</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

View File

@ -22,16 +22,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>

View File

@ -26,32 +26,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>

View File

@ -22,27 +22,13 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<artifactId>spring-jdbc</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -34,16 +34,6 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>

View File

@ -18,10 +18,6 @@
<main.basedir>${basedir}/../..</main.basedir>
</properties>
<dependencies>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
@ -44,5 +40,9 @@
<groupId>com.atomikos</groupId>
<artifactId>transactions-jdbc</artifactId>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -18,6 +18,10 @@
<main.basedir>${basedir}/../..</main.basedir>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms-api</artifactId>
@ -36,9 +40,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -18,14 +18,6 @@
<main.basedir>${basedir}/../..</main.basedir>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
@ -38,5 +30,13 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -18,6 +18,10 @@
<main.basedir>${basedir}/../..</main.basedir>
</properties>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
@ -30,9 +34,5 @@
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -22,16 +22,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>

View File

@ -26,16 +26,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.mobile</groupId>
<artifactId>spring-mobile-device</artifactId>

View File

@ -30,15 +30,5 @@
<groupId>com.samskivert</groupId>
<artifactId>jmustache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

View File

@ -22,24 +22,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>

View File

@ -26,20 +26,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.crashub</groupId>
<artifactId>crash.cli</artifactId>

View File

@ -24,29 +24,7 @@
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<artifactId>spring-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
@ -56,9 +34,5 @@
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -26,16 +26,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-config</artifactId>

View File

@ -26,16 +26,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-config</artifactId>

View File

@ -26,16 +26,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-config</artifactId>

View File

@ -26,16 +26,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>

View File

@ -18,6 +18,10 @@
<main.basedir>${basedir}/../..</main.basedir>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
@ -42,16 +46,6 @@
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-tools</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>

View File

@ -34,16 +34,6 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>

View File

@ -26,16 +26,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>

View File

@ -26,16 +26,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>

View File

@ -27,6 +27,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependency-tools</artifactId>
</dependency>
<dependency>
<groupId>io.spring.gradle</groupId>
<artifactId>dependency-management-plugin</artifactId>
</dependency>
<!-- Provided -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
@ -42,12 +46,7 @@
<groupId>org.gradle</groupId>
<artifactId>gradle-base-services</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gradle</groupId>
<artifactId>gradle-base-services-groovy</artifactId>
<scope>provided</scope>
</dependency>
</dependency>
<dependency>
<groupId>org.gradle</groupId>
<artifactId>gradle-plugins</artifactId>

View File

@ -22,9 +22,8 @@ import org.gradle.api.plugins.ApplicationPlugin
import org.gradle.api.plugins.BasePlugin
import org.gradle.api.plugins.JavaPlugin
import org.springframework.boot.gradle.agent.AgentPluginFeatures
import org.springframework.boot.gradle.exclude.ExcludePluginFeatures
import org.springframework.boot.gradle.dependencymanagement.DependencyManagementPluginFeatures
import org.springframework.boot.gradle.repackage.RepackagePluginFeatures
import org.springframework.boot.gradle.resolve.ResolvePluginFeatures
import org.springframework.boot.gradle.run.RunPluginFeatures
@ -33,23 +32,21 @@ import org.springframework.boot.gradle.run.RunPluginFeatures
*
* @author Phillip Webb
* @author Dave Syer
* @author Andy Wilkinson
*/
class SpringBootPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.getPlugins().apply(BasePlugin)
project.getExtensions().create("springBoot", SpringBootPluginExtension)
project.getConfigurations().create(VersionManagedDependencies.CONFIGURATION);
project.getPlugins().apply(JavaPlugin)
project.getPlugins().apply(ApplicationPlugin)
new AgentPluginFeatures().apply(project)
new RepackagePluginFeatures().apply(project)
new RunPluginFeatures().apply(project)
new ResolvePluginFeatures().apply(project)
new ExcludePluginFeatures().apply(project)
new DependencyManagementPluginFeatures().apply(project)
useUtf8Encoding(project)
}

View File

@ -1,86 +0,0 @@
/*
* 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.gradle;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.springframework.boot.dependency.tools.Dependencies;
import org.springframework.boot.dependency.tools.ManagedDependencies;
import org.springframework.boot.dependency.tools.PropertiesFileDependencies;
/**
* Utility to provide access to {@link ManagedDependencies} with support for version file
* overrides.
*
* @author Phillip Webb
*/
public class VersionManagedDependencies {
public static final String CONFIGURATION = "versionManagement";
private Configuration versionManagementConfiguration;
private Collection<Dependencies> versionManagedDependencies;
private ManagedDependencies managedDependencies;
public VersionManagedDependencies(Project project) {
this.versionManagementConfiguration = project.getConfigurations().getByName(
CONFIGURATION);
}
public ManagedDependencies getManagedDependencies() {
if (this.managedDependencies == null) {
this.managedDependencies = ManagedDependencies
.get(getVersionManagedDependencies());
}
return this.managedDependencies;
}
private Collection<Dependencies> getVersionManagedDependencies() {
if (versionManagedDependencies == null) {
Set<File> files = versionManagementConfiguration.resolve();
List<Dependencies> dependencies = new ArrayList<Dependencies>(files.size());
for (File file : files) {
dependencies.add(getPropertiesFileManagedDependencies(file));
}
this.versionManagedDependencies = dependencies;
}
return versionManagedDependencies;
}
private Dependencies getPropertiesFileManagedDependencies(File file) {
if (!file.getName().toLowerCase().endsWith(".properties")) {
throw new IllegalStateException(file + " is not a version property file");
}
try {
return new PropertiesFileDependencies(new FileInputStream(file));
}
catch (IOException ex) {
throw new IllegalStateException(ex);
}
}
}

View File

@ -0,0 +1,42 @@
/*
* Copyright 2012-2015 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.gradle.dependencymanagement;
import io.spring.gradle.dependencymanagement.DependencyManagementExtension
import io.spring.gradle.dependencymanagement.DependencyManagementPlugin
import org.gradle.api.Project
import org.springframework.boot.gradle.PluginFeatures
/**
* {@link PluginFeatures} to configure dependency management
*
* @author Andy Wilkinson
*/
class DependencyManagementPluginFeatures implements PluginFeatures {
@Override
void apply(Project project) {
project.plugins.apply(DependencyManagementPlugin)
DependencyManagementExtension dependencyManagement = project.extensions
.findByType(DependencyManagementExtension)
dependencyManagement.imports {
def version = DependencyManagementPluginFeatures.class.getPackage().implementationVersion
mavenBom "org.springframework.boot:spring-boot-starter-parent:$version"
}
}
}

View File

@ -1,115 +0,0 @@
/*
* 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.gradle.exclude;
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.ModuleDependency;
import org.gradle.api.artifacts.ResolvableDependencies;
import org.gradle.api.internal.artifacts.DefaultExcludeRule;
import org.gradle.api.logging.Logger;
import org.springframework.boot.dependency.tools.Dependency.Exclusion;
import org.springframework.boot.dependency.tools.ManagedDependencies;
import org.springframework.boot.gradle.VersionManagedDependencies;
/**
* {@link Action} to apply exclude rules.
*
* @author Phillip Webb
*/
public class ApplyExcludeRules implements Action<Configuration> {
private final Logger logger;
private final VersionManagedDependencies versionManagedDependencies;
public ApplyExcludeRules(Project project) {
this.logger = project.getLogger();
this.versionManagedDependencies = new VersionManagedDependencies(project);
}
@Override
public void execute(Configuration configuration) {
if (!VersionManagedDependencies.CONFIGURATION.equals(configuration.getName())) {
configuration.getIncoming().beforeResolve(
new Action<ResolvableDependencies>() {
@Override
public void execute(ResolvableDependencies resolvableDependencies) {
resolvableDependencies.getDependencies().all(
new Action<Dependency>() {
@Override
public void execute(Dependency dependency) {
applyExcludeRules(dependency);
}
});
}
});
}
}
private void applyExcludeRules(Dependency dependency) {
if (dependency instanceof ModuleDependency) {
applyExcludeRules((ModuleDependency) dependency);
}
}
private void applyExcludeRules(ModuleDependency dependency) {
ManagedDependencies managedDependencies = versionManagedDependencies
.getManagedDependencies();
// flat directory repositories do not have groups
if (dependency.getGroup() != null) {
org.springframework.boot.dependency.tools.Dependency managedDependency = managedDependencies
.find(dependency.getGroup(), dependency.getName());
if (managedDependency != null) {
for (Exclusion exclusion : managedDependency.getExclusions()) {
addExcludeRule(dependency, exclusion);
}
addImplicitExcludeRules(dependency);
return;
}
}
logger.debug("No exclusions rules applied for non-managed dependency "
+ dependency);
}
private void addExcludeRule(ModuleDependency dependency, Exclusion exclusion) {
logger.info("Adding managed exclusion rule " + exclusion + " to " + dependency);
DefaultExcludeRule rule = new DefaultExcludeRule(exclusion.getGroupId(),
exclusion.getArtifactId());
dependency.getExcludeRules().add(rule);
}
private void addImplicitExcludeRules(ModuleDependency dependency) {
if (isStarter(dependency)) {
logger.info("Adding implicit managed exclusion rules to starter "
+ dependency);
dependency.getExcludeRules().add(
new DefaultExcludeRule("commons-logging", "commons-logging"));
dependency.getExcludeRules().add(
new DefaultExcludeRule("commons-logging", "commons-logging-api"));
}
}
private boolean isStarter(ModuleDependency dependency) {
return (dependency.getGroup() != null
&& dependency.getGroup().equals("org.springframework.boot") && dependency
.getName().startsWith("spring-boot-starter"));
}
}

View File

@ -1,39 +0,0 @@
/*
* 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.gradle.exclude;
import org.gradle.api.Project;
import org.springframework.boot.gradle.PluginFeatures;
import org.springframework.boot.gradle.SpringBootPluginExtension;
/**
* {@link PluginFeatures} to apply exclusion rules.
*
* @author Phillip Webb
*/
public class ExcludePluginFeatures implements PluginFeatures {
@Override
public void apply(Project project) {
SpringBootPluginExtension extension = project.getExtensions().getByType(
SpringBootPluginExtension.class);
if (extension.isApplyExcludeRules()) {
project.getConfigurations().all(new ApplyExcludeRules(project));
}
}
}

View File

@ -1,41 +0,0 @@
/*
* 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.gradle.resolve;
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.springframework.boot.gradle.PluginFeatures;
/**
* {@link PluginFeatures} to add version resolution support.
*
* @author Phillip Webb
*/
public class ResolvePluginFeatures implements PluginFeatures {
@Override
public void apply(final Project project) {
project.getConfigurations().all(new Action<Configuration>() {
@Override
public void execute(Configuration configuration) {
SpringBootResolutionStrategy.applyToConfiguration(project, configuration);
}
});
}
}

View File

@ -1,79 +0,0 @@
/*
* 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.gradle.resolve;
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.DependencyResolveDetails;
import org.gradle.api.artifacts.ModuleVersionSelector;
import org.springframework.boot.dependency.tools.Dependency;
import org.springframework.boot.dependency.tools.ManagedDependencies;
import org.springframework.boot.gradle.VersionManagedDependencies;
/**
* A resolution strategy to resolve missing version numbers using the
* 'spring-boot-dependencies' POM.
*
* @author Phillip Webb
*/
public class SpringBootResolutionStrategy {
private static final String SPRING_BOOT_GROUP = "org.springframework.boot";
public static void applyToConfiguration(final Project project,
Configuration configuration) {
if (VersionManagedDependencies.CONFIGURATION.equals(configuration.getName())) {
return;
}
VersionResolver versionResolver = new VersionResolver(project);
configuration.getResolutionStrategy().eachDependency(versionResolver);
}
private static class VersionResolver implements Action<DependencyResolveDetails> {
private final VersionManagedDependencies versionManagedDependencies;
public VersionResolver(Project project) {
this.versionManagedDependencies = new VersionManagedDependencies(project);
}
@Override
public void execute(DependencyResolveDetails resolveDetails) {
String version = resolveDetails.getTarget().getVersion();
if (version == null || version.trim().length() == 0) {
resolve(resolveDetails);
}
}
private void resolve(DependencyResolveDetails resolveDetails) {
ManagedDependencies dependencies = this.versionManagedDependencies
.getManagedDependencies();
ModuleVersionSelector target = resolveDetails.getTarget();
if (SPRING_BOOT_GROUP.equals(target.getGroup())) {
resolveDetails.useVersion(dependencies.getSpringBootVersion());
return;
}
Dependency dependency = dependencies
.find(target.getGroup(), target.getName());
if (dependency != null) {
resolveDetails.useVersion(dependency.getVersion());
}
}
}
}