Automatically create developmentOnly configuration

Previously, the developmentOnly configuration, typically used for
Devtools, had to be declared manually. The BootJar and BootWar tasks
then had a property, excludeDevtools, that could be used to control
whether or not Devtools would be excluded from the executable archive.

This commit updates the reaction to the Java plugin being applied to
automatically create the developmentOnly configuration. The classpaths
of bootJar and bootWar are then configured not to include the contents
of the developmentOnly configuration. As a result of this, the
excludeDevtools property is no longer needed and has been deprecated.
Its default has also been changed from true to false to make it easy
to opt in to Devtools, when configured as a development-only
dependency, being included in executable jars and wars by adding
developmentOnly to the classpath of the archive task.

Closes gh-16599
This commit is contained in:
Andy Wilkinson
2020-04-27 12:00:08 +01:00
parent cbdc5d9746
commit fb33610027
21 changed files with 196 additions and 30 deletions

View File

@@ -19,3 +19,9 @@ task('javaCompileEncoding') {
}
}
}
task('configurationExists') {
doFirst {
println "${configurationName} exists = ${configurations.findByName(configurationName) != null}"
}
}

View File

@@ -0,0 +1,17 @@
plugins {
id 'java'
id 'org.springframework.boot' version '{version}'
}
bootJar {
mainClassName = 'com.example.Application'
}
repositories {
mavenCentral()
}
dependencies {
developmentOnly("org.apache.commons:commons-lang3:3.9")
implementation("commons-io:commons-io:2.6")
}

View File

@@ -0,0 +1,17 @@
plugins {
id 'java'
id 'org.springframework.boot' version '{version}'
}
bootJar {
mainClassName = 'com.example.Application'
}
repositories {
mavenCentral()
}
dependencies {
developmentOnly("org.apache.commons:commons-lang3:3.9")
implementation("commons-io:commons-io:2.6")
}

View File

@@ -0,0 +1,21 @@
plugins {
id 'java'
id 'org.springframework.boot' version '{version}'
}
bootJar {
mainClassName = 'com.example.Application'
}
repositories {
mavenCentral()
}
dependencies {
developmentOnly("org.apache.commons:commons-lang3:3.9")
implementation("commons-io:commons-io:2.6")
}
bootJar {
classpath configurations.developmentOnly
}

View File

@@ -0,0 +1,17 @@
plugins {
id 'war'
id 'org.springframework.boot' version '{version}'
}
bootWar {
mainClassName = 'com.example.Application'
}
repositories {
mavenCentral()
}
dependencies {
developmentOnly("org.apache.commons:commons-lang3:3.9")
implementation("commons-io:commons-io:2.6")
}

View File

@@ -0,0 +1,21 @@
plugins {
id 'war'
id 'org.springframework.boot' version '{version}'
}
bootWar {
mainClassName = 'com.example.Application'
}
repositories {
mavenCentral()
}
dependencies {
developmentOnly("org.apache.commons:commons-lang3:3.9")
implementation("commons-io:commons-io:2.6")
}
bootWar {
classpath configurations.developmentOnly
}