Raise the minimum supported version of Gradle to 7.3

Closes gh-28100
pull/28862/head
Andy Wilkinson 3 years ago
parent 4e884b27f8
commit 814c86c5e8

@ -38,6 +38,7 @@ public class DeployedPlugin implements Plugin<Project> {
public static final String GENERATE_POM_TASK_NAME = "generatePomFileForMavenPublication";
@Override
@SuppressWarnings("deprecation")
public void apply(Project project) {
project.getPlugins().apply(MavenPublishPlugin.class);
project.getPlugins().apply(MavenRepositoryPlugin.class);

@ -22,7 +22,6 @@ import org.gradle.api.attributes.Usage;
import org.gradle.api.component.AdhocComponentWithVariants;
import org.gradle.api.component.ConfigurationVariantDetails;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.VariantVersionMappingStrategy;
@ -115,9 +114,8 @@ class MavenPublishingConventions {
*/
private void addMavenOptionalFeature(Project project) {
JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class);
extension.registerFeature("mavenOptional",
(feature) -> feature.usingSourceSet(convention.getSourceSets().getByName("main")));
(feature) -> feature.usingSourceSet(extension.getSourceSets().getByName("main")));
AdhocComponentWithVariants javaComponent = (AdhocComponentWithVariants) project.getComponents()
.findByName("java");
javaComponent.addVariantsFromConfiguration(

@ -24,7 +24,7 @@ import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.SourceSet;
import org.springframework.boot.build.DeployedPlugin;
@ -66,7 +66,7 @@ public class AutoConfigurationPlugin implements Plugin<Project> {
.add(project.getDependencies().project(Collections.singletonMap("path",
":spring-boot-project:spring-boot-tools:spring-boot-configuration-processor")));
project.getTasks().create("autoConfigurationMetadata", AutoConfigurationMetadata.class, (task) -> {
SourceSet main = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
SourceSet main = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
task.setSourceSet(main);
task.dependsOn(main.getClassesTaskName());

@ -21,8 +21,8 @@ import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import groovy.namespace.QName;
import groovy.util.Node;
import groovy.xml.QName;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;

@ -84,6 +84,7 @@ public class UpgradeBom extends DefaultTask {
}
@TaskAction
@SuppressWarnings("deprecation")
void upgradeDependencies() {
GitHubRepository repository = createGitHub().getRepository(this.bom.getUpgrade().getGitHub().getOrganization(),
this.bom.getUpgrade().getGitHub().getRepository());

@ -16,9 +16,7 @@
package org.springframework.boot.build.context.properties;
import java.io.File;
import java.util.Collections;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import org.gradle.api.Plugin;
@ -26,7 +24,7 @@ import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.PathSensitivity;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.compile.JavaCompile;
@ -74,13 +72,12 @@ public class ConfigurationPropertiesPlugin implements Plugin<Project> {
}
private void addMetadataArtifact(Project project) {
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
project.getConfigurations().maybeCreate(CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME);
project.afterEvaluate((evaluatedProject) -> evaluatedProject.getArtifacts().add(
CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME,
evaluatedProject.provider((Callable<File>) () -> new File(mainSourceSet.getJava().getOutputDir(),
"META-INF/spring-configuration-metadata.json")),
mainSourceSet.getJava().getDestinationDirectory().dir("META-INF/spring-configuration-metadata.json"),
(artifact) -> artifact
.builtBy(evaluatedProject.getTasks().getByName(mainSourceSet.getClassesTaskName()))));
}
@ -90,7 +87,7 @@ public class ConfigurationPropertiesPlugin implements Plugin<Project> {
.getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME);
((Task) compileJava).getInputs().files(project.getTasks().getByName(JavaPlugin.PROCESS_RESOURCES_TASK_NAME))
.withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("processed resources");
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
compileJava.getOptions().getCompilerArgs()
.add("-Aorg.springframework.boot.configurationprocessor.additionalMetadataLocations=" + StringUtils

@ -41,7 +41,7 @@ public class ReproducibleLog4j2PluginsDatAction implements Action<JavaCompile> {
@Override
public void execute(JavaCompile javaCompile) {
File datFile = new File(javaCompile.getDestinationDir(),
File datFile = new File(javaCompile.getDestinationDirectory().getAsFile().get(),
"META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat");
try {
postProcess(datFile);

@ -46,7 +46,7 @@ public class MavenExec extends JavaExec {
public MavenExec() throws IOException {
setClasspath(mavenConfiguration(getProject()));
args("--batch-mode");
setMain("org.apache.maven.cli.MavenCli");
getMainClass().set("org.apache.maven.cli.MavenCli");
}
public void setProjectDir(File projectDir) {

@ -42,7 +42,7 @@ import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.plugins.JavaLibraryPlugin;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.maven.MavenPublication;
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
@ -180,7 +180,7 @@ public class MavenPluginPlugin implements Plugin<Project> {
}
private SourceSet getMainSourceSet(Project project) {
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
return sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
}

@ -20,7 +20,7 @@ import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.SourceSetContainer;
/**
@ -44,7 +44,7 @@ public class OptionalDependenciesPlugin implements Plugin<Project> {
optional.setCanBeConsumed(false);
optional.setCanBeResolved(false);
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> {
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class)
SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class)
.getSourceSets();
sourceSets.all((sourceSet) -> {
project.getConfigurations().getByName(sourceSet.getCompileClasspathConfigurationName())

@ -19,7 +19,7 @@ package org.springframework.boot.build.test;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.testing.Test;
@ -61,7 +61,7 @@ public class IntegrationTestPlugin implements Plugin<Project> {
}
private SourceSet createSourceSet(Project project) {
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
SourceSet intTestSourceSet = sourceSets.create(INT_TEST_SOURCE_SET_NAME);
SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
intTestSourceSet.setCompileClasspath(intTestSourceSet.getCompileClasspath().plus(main.getOutput()));

@ -19,7 +19,7 @@ package org.springframework.boot.build.test;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.testing.Test;
@ -61,7 +61,7 @@ public class SystemTestPlugin implements Plugin<Project> {
}
private SourceSet createSourceSet(Project project) {
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
SourceSet systemTestSourceSet = sourceSets.create(SYSTEM_TEST_SOURCE_SET_NAME);
SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
systemTestSourceSet

Binary file not shown.

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

257
gradlew vendored

@ -1,7 +1,7 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright 2015 the original author or authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -17,67 +17,101 @@
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
@ -106,80 +140,95 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
i=`expr $i + 1`
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

@ -187,7 +187,10 @@ class ThreadDumpEndpointDocumentationTests extends MockMvcEndpointDocumentationT
.andDo(MockMvcRestDocumentation.document("threaddump/text",
preprocessResponse(new ContentModifyingOperationPreprocessor((bytes, mediaType) -> {
String content = new String(bytes, StandardCharsets.UTF_8);
return content.substring(0, content.indexOf("\"main\" - Thread")).getBytes();
int mainThreadIndex = content.indexOf("\"main\" - Thread");
String truncatedContent = (mainThreadIndex >= 0) ? content.substring(0, mainThreadIndex)
: content;
return truncatedContent.getBytes();
}))));
}

@ -1,7 +1,7 @@
[[build-tool-plugins.gradle]]
== Spring Boot Gradle Plugin
The Spring Boot Gradle Plugin provides Spring Boot support in Gradle, letting you package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by `spring-boot-dependencies`.
It requires Gradle 6.8, 6.9, or 7.x.
It requires Gradle 7.x (7.3 or later).
See the plugin's documentation to learn more:
* Reference ({spring-boot-gradle-plugin-docs}[HTML] and {spring-boot-gradle-plugin-pdfdocs}[PDF])

@ -45,7 +45,7 @@ More details on getting started with Spring Boot and Maven can be found in the {
[[getting-started.installing.java.gradle]]
==== Gradle Installation
Spring Boot is compatible with Gradle 6.8, 6.9, and 7.x.
Spring Boot is compatible with Gradle 7.x (7.3 or later).
If you do not already have Gradle installed, you can follow the instructions at https://gradle.org.
Spring Boot dependencies can be declared by using the `org.springframework.boot` `group`.

@ -12,7 +12,7 @@ Explicit build support is provided for the following build tools:
| 3.5+
| Gradle
| 6.8.x, 6.9.x, and 7.x
| 7.x (7.3 or later)
|===

@ -189,3 +189,8 @@ bom {
dependencies {
api(enforcedPlatform(project(":spring-boot-project:spring-boot-dependencies")))
}
tasks.withType(GenerateModuleMetadata).configureEach {
// Internal module so enforced platform dependencies are OK
suppressedValidationErrors.add('enforced-platform')
}

@ -2,6 +2,6 @@
= Introduction
The Spring Boot Gradle Plugin provides Spring Boot support in https://gradle.org[Gradle].
It allows you to package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by `spring-boot-dependencies`.
Spring Boot's Gradle plugin requires Gradle 6.8, 6.9, or 7.x and can be used with Gradle's {gradle-userguide}/configuration_cache.html[configuration cache].
Spring Boot's Gradle plugin requires Gradle 7.x (7.3 or later) and can be used with Gradle's {gradle-userguide}/configuration_cache.html[configuration cache].
In addition to this user guide, {api-documentation}[API documentation] is also available.

@ -23,29 +23,6 @@ include::../gradle/publishing/maven-publish.gradle.kts[tags=publishing]
[[publishing-your-application.maven]]
== Publishing with the Maven Plugin
WARNING: Due to its deprecation in Gradle 6, this plugin's support for publishing with Gradle's `maven` plugin is deprecated and will be removed in a future release.
Please use the `maven-publish` plugin instead.
When the {maven-plugin}[`maven` plugin] is applied, an `Upload` task for the `bootArchives` configuration named `uploadBootArchives` is automatically created.
By default, the `bootArchives` configuration contains the archive produced by the `bootJar` or `bootWar` task.
The `uploadBootArchives` task can be configured to publish the archive to a Maven repository:
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
.Groovy
----
include::../gradle/publishing/maven.gradle[tags=upload]
----
[source,kotlin,indent=0,subs="verbatim,attributes",role="secondary"]
.Kotlin
----
include::../gradle/publishing/maven.gradle.kts[tags=upload]
----
[[publishing-your-application.distribution]]
== Distributing with the Application Plugin
When the {application-plugin}[`application` plugin] is applied a distribution named `boot` is created.

@ -63,11 +63,3 @@ When Gradle's {application-plugin}[`application` plugin] is applied to a project
5. Configures the `bootJar` task to use the `mainClassName` property as a convention for the `Start-Class` entry in its manifest.
6. Configures the `bootWar` task to use the `mainClassName` property as a convention for the `Start-Class` entry in its manifest.
[[reacting-to-other-plugins.maven]]
== Reacting to the Maven plugin
WARNING: Support for reacting to Gradle's `maven` plugin is deprecated and will be removed in a future release.
Please use the `maven-publish` plugin instead.
When Gradle's {maven-plugin}[`maven` plugin] is applied to a project, the Spring Boot plugin will configure the `uploadBootArchives` `Upload` task to ensure that no dependencies are declared in the pom that it generates.

@ -1,21 +0,0 @@
plugins {
id 'java'
id 'maven'
id 'org.springframework.boot' version '{gradle-project-version}'
}
// tag::upload[]
uploadBootArchives {
repositories {
mavenDeployer {
repository url: 'https://repo.example.com'
}
}
}
// end::upload[]
task deployerRepository {
doLast {
println uploadBootArchives.repositories.mavenDeployer.repository.url
}
}

@ -1,26 +0,0 @@
plugins {
java
maven
id("org.springframework.boot") version "{gradle-project-version}"
}
// tag::upload[]
tasks.getByName<Upload>("uploadBootArchives") {
repositories.withGroovyBuilder {
"mavenDeployer" {
"repository"("url" to "https://repo.example.com")
}
}
}
// end::upload[]
val url = tasks.getByName<Upload>("uploadBootArchives")
.repositories
.withGroovyBuilder { getProperty("mavenDeployer") }
.withGroovyBuilder { getProperty("repository") }
.withGroovyBuilder { getProperty("url") }
task("deployerRepository") {
doLast {
println(url)
}
}

@ -5,7 +5,7 @@ plugins {
// tag::main[]
bootRun {
main = 'com.example.ExampleApplication'
mainClass = 'com.example.ExampleApplication'
}
// end::main[]

@ -7,12 +7,12 @@ plugins {
// tag::main[]
tasks.getByName<BootRun>("bootRun") {
main = "com.example.ExampleApplication"
mainClass.set("com.example.ExampleApplication")
}
// end::main[]
task("configuredMainClass") {
doLast {
println(tasks.getByName<BootRun>("bootRun").main)
println(tasks.getByName<BootRun>("bootRun").mainClass.get())
}
}

@ -22,7 +22,7 @@ import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.TaskContainer;
@ -112,7 +112,7 @@ public class SpringBootExtension {
}
private File determineMainSourceSetResourcesOutputDir() {
return this.project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
return this.project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput().getResourcesDir();
}

@ -32,7 +32,7 @@ import org.gradle.api.file.CopySpec;
import org.gradle.api.file.FileCollection;
import org.gradle.api.internal.IConventionAware;
import org.gradle.api.plugins.ApplicationPlugin;
import org.gradle.api.plugins.ApplicationPluginConvention;
import org.gradle.api.plugins.JavaApplication;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.jvm.application.scripts.TemplateBasedScriptGenerator;
@ -50,11 +50,10 @@ final class ApplicationPluginAction implements PluginApplicationAction {
@Override
public void execute(Project project) {
ApplicationPluginConvention applicationConvention = project.getConvention()
.getPlugin(ApplicationPluginConvention.class);
JavaApplication javaApplication = project.getExtensions().getByType(JavaApplication.class);
DistributionContainer distributions = project.getExtensions().getByType(DistributionContainer.class);
Distribution distribution = distributions.create("boot");
configureBaseNameConvention(project, applicationConvention, distribution);
configureBaseNameConvention(project, javaApplication, distribution);
CreateStartScripts bootStartScripts = project.getTasks().create("bootStartScripts",
determineCreateStartScriptsClass());
bootStartScripts
@ -73,9 +72,8 @@ final class ApplicationPluginAction implements PluginApplicationAction {
}
});
bootStartScripts.getConventionMapping().map("outputDir", () -> new File(project.getBuildDir(), "bootScripts"));
bootStartScripts.getConventionMapping().map("applicationName", applicationConvention::getApplicationName);
bootStartScripts.getConventionMapping().map("defaultJvmOpts",
applicationConvention::getApplicationDefaultJvmArgs);
bootStartScripts.getConventionMapping().map("applicationName", javaApplication::getApplicationName);
bootStartScripts.getConventionMapping().map("defaultJvmOpts", javaApplication::getApplicationDefaultJvmArgs);
CopySpec binCopySpec = project.copySpec().into("bin").from(bootStartScripts);
binCopySpec.setFileMode(0755);
distribution.getContents().with(binCopySpec);
@ -90,7 +88,7 @@ final class ApplicationPluginAction implements PluginApplicationAction {
}
@SuppressWarnings("unchecked")
private void configureBaseNameConvention(Project project, ApplicationPluginConvention applicationConvention,
private void configureBaseNameConvention(Project project, JavaApplication javaApplication,
Distribution distribution) {
Method getDistributionBaseName = findMethod(distribution.getClass(), "getDistributionBaseName");
if (getDistributionBaseName != null) {
@ -98,7 +96,7 @@ final class ApplicationPluginAction implements PluginApplicationAction {
Property<String> distributionBaseName = (Property<String>) distribution.getClass()
.getMethod("getDistributionBaseName").invoke(distribution);
distributionBaseName.getClass().getMethod("convention", Provider.class).invoke(distributionBaseName,
project.provider(() -> applicationConvention.getApplicationName() + "-boot"));
project.provider(() -> javaApplication.getApplicationName() + "-boot"));
return;
}
catch (Exception ex) {
@ -107,7 +105,7 @@ final class ApplicationPluginAction implements PluginApplicationAction {
}
if (distribution instanceof IConventionAware) {
((IConventionAware) distribution).getConventionMapping().map("baseName",
() -> applicationConvention.getApplicationName() + "-boot");
() -> javaApplication.getApplicationName() + "-boot");
}
}

@ -36,7 +36,6 @@ import org.gradle.api.model.ObjectFactory;
import org.gradle.api.plugins.ApplicationPlugin;
import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.SourceSet;
@ -99,7 +98,7 @@ final class JavaPluginAction implements PluginApplicationAction {
}
private TaskProvider<BootJar> configureBootJarTask(Project project) {
SourceSet mainSourceSet = javaPluginConvention(project).getSourceSets()
SourceSet mainSourceSet = javaPluginExtension(project).getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
Configuration developmentOnly = project.getConfigurations()
.getByName(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME);
@ -127,7 +126,7 @@ final class JavaPluginAction implements PluginApplicationAction {
buildImage.setGroup(BasePlugin.BUILD_GROUP);
buildImage.getArchiveFile().set(bootJar.get().getArchiveFile());
buildImage.getTargetJavaVersion()
.set(project.provider(() -> javaPluginConvention(project).getTargetCompatibility()));
.set(project.provider(() -> javaPluginExtension(project).getTargetCompatibility()));
});
}
@ -137,7 +136,7 @@ final class JavaPluginAction implements PluginApplicationAction {
}
private void configureBootRunTask(Project project) {
FileCollection classpath = javaPluginConvention(project).getSourceSets()
FileCollection classpath = javaPluginExtension(project).getSourceSets()
.findByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath().filter(new JarTypeFileSpec());
TaskProvider<ResolveMainClassName> resolveProvider = ResolveMainClassName.registerForTask("bootRun", project,
classpath);
@ -168,8 +167,8 @@ final class JavaPluginAction implements PluginApplicationAction {
return GradleVersion.current().getBaseVersion().compareTo(GradleVersion.version("6.7")) >= 0;
}
private JavaPluginConvention javaPluginConvention(Project project) {
return project.getConvention().getPlugin(JavaPluginConvention.class);
private JavaPluginExtension javaPluginExtension(Project project) {
return project.getExtensions().getByType(JavaPluginExtension.class);
}
private void configureUtf8Encoding(Project project) {
@ -195,7 +194,7 @@ final class JavaPluginAction implements PluginApplicationAction {
}
private void configureAdditionalMetadataLocations(JavaCompile compile) {
SourceSetContainer sourceSets = compile.getProject().getConvention().getPlugin(JavaPluginConvention.class)
SourceSetContainer sourceSets = compile.getProject().getExtensions().getByType(JavaPluginExtension.class)
.getSourceSets();
sourceSets.stream().filter((candidate) -> candidate.getCompileJavaTaskName().equals(compile.getName()))
.map((match) -> match.getResources().getSrcDirs()).findFirst()

@ -1,60 +0,0 @@
/*
* Copyright 2012-2021 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
*
* https://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.plugin;
import org.gradle.api.Action;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
import org.gradle.api.tasks.Upload;
/**
* {@link Action} that is executed in response to the
* {@link org.gradle.api.plugins.MavenPlugin} being applied.
*
* @author Andy Wilkinson
* @deprecated since 2.5.0 in favor of using the {@link MavenPublishPlugin}
*/
@Deprecated
final class MavenPluginAction implements PluginApplicationAction {
private final String uploadTaskName;
MavenPluginAction(String uploadTaskName) {
this.uploadTaskName = uploadTaskName;
}
@Override
public Class<? extends Plugin<? extends Project>> getPluginClass() {
return org.gradle.api.plugins.MavenPlugin.class;
}
@Override
public void execute(Project project) {
project.getTasks().withType(Upload.class, (upload) -> {
if (this.uploadTaskName.equals(upload.getName())) {
project.afterEvaluate((evaluated) -> clearConfigurationMappings(upload));
}
});
}
private void clearConfigurationMappings(Upload upload) {
upload.getRepositories().withType(org.gradle.api.artifacts.maven.MavenResolver.class,
(resolver) -> resolver.getPom().getScopeMappings().getMappings().clear());
}
}

@ -33,7 +33,7 @@ import org.gradle.api.file.FileCollection;
import org.gradle.api.file.RegularFile;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.plugins.Convention;
import org.gradle.api.plugins.ExtensionContainer;
import org.gradle.api.plugins.JavaApplication;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
@ -43,6 +43,7 @@ import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.work.DisableCachingByDefault;
import org.springframework.boot.gradle.dsl.SpringBootExtension;
import org.springframework.boot.loader.tools.MainClassFinder;
@ -53,6 +54,7 @@ import org.springframework.boot.loader.tools.MainClassFinder;
* @author Andy Wilkinson
* @since 2.4
*/
@DisableCachingByDefault(because = "Not worth caching")
public class ResolveMainClassName extends DefaultTask {
private static final String SPRING_BOOT_APPLICATION_CLASS_NAME = "org.springframework.boot.autoconfigure.SpringBootApplication";
@ -145,13 +147,13 @@ public class ResolveMainClassName extends DefaultTask {
FileCollection classpath) {
TaskProvider<ResolveMainClassName> resolveMainClassNameProvider = project.getTasks()
.register(taskName + "MainClassName", ResolveMainClassName.class, (resolveMainClassName) -> {
Convention convention = project.getConvention();
ExtensionContainer extensions = project.getExtensions();
resolveMainClassName.setDescription(
"Resolves the name of the application's main class for the " + taskName + " task.");
resolveMainClassName.setGroup(BasePlugin.BUILD_GROUP);
resolveMainClassName.setClasspath(classpath);
resolveMainClassName.getConfiguredMainClassName().convention(project.provider(() -> {
String javaApplicationMainClass = getJavaApplicationMainClass(convention);
String javaApplicationMainClass = getJavaApplicationMainClass(extensions);
if (javaApplicationMainClass != null) {
return javaApplicationMainClass;
}
@ -166,8 +168,8 @@ public class ResolveMainClassName extends DefaultTask {
}
@SuppressWarnings("deprecation")
private static String getJavaApplicationMainClass(Convention convention) {
JavaApplication javaApplication = convention.findByType(JavaApplication.class);
private static String getJavaApplicationMainClass(ExtensionContainer extensions) {
JavaApplication javaApplication = extensions.findByType(JavaApplication.class);
if (javaApplication == null) {
return null;
}

@ -117,10 +117,9 @@ public class SpringBootPlugin implements Plugin<Project> {
private void registerPluginActions(Project project, Configuration bootArchives) {
SinglePublishedArtifact singlePublishedArtifact = new SinglePublishedArtifact(bootArchives.getArtifacts());
@SuppressWarnings("deprecation")
List<PluginApplicationAction> actions = Arrays.asList(new JavaPluginAction(singlePublishedArtifact),
new WarPluginAction(singlePublishedArtifact), new MavenPluginAction(bootArchives.getUploadTaskName()),
new DependencyManagementPluginAction(), new ApplicationPluginAction(), new KotlinPluginAction());
new WarPluginAction(singlePublishedArtifact), new DependencyManagementPluginAction(),
new ApplicationPluginAction(), new KotlinPluginAction());
for (PluginApplicationAction action : actions) {
withPluginClassOfAction(action,
(pluginClass) -> project.getPlugins().withType(pluginClass, (plugin) -> action.execute(project)));

@ -71,7 +71,7 @@ class WarPluginAction implements PluginApplicationAction {
.getByName(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME);
Configuration productionRuntimeClasspath = project.getConfigurations()
.getByName(SpringBootPlugin.PRODUCTION_RUNTIME_CLASSPATH_CONFIGURATION_NAME);
FileCollection classpath = project.getConvention().getByType(SourceSetContainer.class)
FileCollection classpath = project.getExtensions().getByType(SourceSetContainer.class)
.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath()
.minus(providedRuntimeConfiguration(project)).minus((developmentOnly.minus(productionRuntimeClasspath)))
.filter(new JarTypeFileSpec());

@ -30,6 +30,7 @@ public class CreateBootStartScripts extends CreateStartScripts {
@Override
@Optional
@Deprecated
public String getMainClassName() {
return super.getMainClassName();
}

@ -30,6 +30,7 @@ import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskExecutionException;
import org.gradle.work.DisableCachingByDefault;
import org.springframework.boot.loader.tools.BuildPropertiesWriter;
import org.springframework.boot.loader.tools.BuildPropertiesWriter.ProjectDetails;
@ -41,6 +42,7 @@ import org.springframework.boot.loader.tools.BuildPropertiesWriter.ProjectDetail
* @author Andy Wilkinson
* @since 2.0.0
*/
@DisableCachingByDefault(because = "Not worth caching")
public class BuildInfo extends ConventionTask {
private final BuildInfoProperties properties = new BuildInfoProperties(getProject());

@ -22,7 +22,6 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import groovy.lang.Closure;
import org.gradle.api.Action;
import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
@ -37,7 +36,7 @@ import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.options.Option;
import org.gradle.util.ConfigureUtil;
import org.gradle.work.DisableCachingByDefault;
import org.springframework.boot.buildpack.platform.build.BuildRequest;
import org.springframework.boot.buildpack.platform.build.Builder;
@ -63,6 +62,7 @@ import org.springframework.util.StringUtils;
* @author Julian Liebig
* @since 2.3.0
*/
@DisableCachingByDefault
public class BootBuildImage extends DefaultTask {
private static final String BUILDPACK_JVM_VERSION_KEY = "BP_JVM_VERSION";
@ -99,11 +99,11 @@ public class BootBuildImage extends DefaultTask {
private final ListProperty<String> tags;
private final CacheSpec buildCache = new CacheSpec();
private final CacheSpec buildCache;
private final CacheSpec launchCache = new CacheSpec();
private final CacheSpec launchCache;
private final DockerSpec docker = new DockerSpec();
private final DockerSpec docker;
public BootBuildImage() {
this.archiveFile = getProject().getObjects().fileProperty();
@ -115,6 +115,9 @@ public class BootBuildImage extends DefaultTask {
this.buildpacks = getProject().getObjects().listProperty(String.class);
this.bindings = getProject().getObjects().listProperty(String.class);
this.tags = getProject().getObjects().listProperty(String.class);
this.buildCache = getProject().getObjects().newInstance(CacheSpec.class);
this.launchCache = getProject().getObjects().newInstance(CacheSpec.class);
this.docker = getProject().getObjects().newInstance(DockerSpec.class);
}
/**
@ -460,15 +463,6 @@ public class BootBuildImage extends DefaultTask {
action.execute(this.buildCache);
}
/**
* Customizes the {@link CacheSpec} for the build cache using the given
* {@code closure}.
* @param closure the closure
*/
public void buildCache(Closure<?> closure) {
buildCache(ConfigureUtil.configureUsing(closure));
}
/**
* Returns the launch cache that will be used when building the image.
* @return the cache
@ -488,15 +482,6 @@ public class BootBuildImage extends DefaultTask {
action.execute(this.launchCache);
}
/**
* Customizes the {@link CacheSpec} for the launch cache using the given
* {@code closure}.
* @param closure the closure
*/
public void launchCache(Closure<?> closure) {
launchCache(ConfigureUtil.configureUsing(closure));
}
/**
* Returns the Docker configuration the builder will use.
* @return docker configuration.
@ -516,15 +501,6 @@ public class BootBuildImage extends DefaultTask {
action.execute(this.docker);
}
/**
* Configures the Docker connection using the given {@code closure}.
* @param closure the closure to apply
* @since 2.4.0
*/
public void docker(Closure<?> closure) {
docker(ConfigureUtil.configureUsing(closure));
}
@TaskAction
void buildImage() throws DockerEngineException, IOException {
Builder builder = new Builder(this.docker.asDockerConfiguration());

@ -34,6 +34,7 @@ import org.gradle.api.specs.Spec;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.bundling.Jar;
import org.gradle.work.DisableCachingByDefault;
/**
* A custom {@link Jar} task that produces a Spring Boot executable jar.
@ -44,6 +45,7 @@ import org.gradle.api.tasks.bundling.Jar;
* @author Phillip Webb
* @since 2.0.0
*/
@DisableCachingByDefault(because = "Not worth caching")
public class BootJar extends Jar implements BootArchive {
private static final String LAUNCHER = "org.springframework.boot.loader.JarLauncher";
@ -64,9 +66,9 @@ public class BootJar extends Jar implements BootArchive {
private final Property<String> mainClass;
private FileCollection classpath;
private final LayeredSpec layered;
private LayeredSpec layered = new LayeredSpec();
private FileCollection classpath;
/**
* Creates a new {@code BootJar} task.
@ -76,6 +78,7 @@ public class BootJar extends Jar implements BootArchive {
Project project = getProject();
this.bootInfSpec = project.copySpec().into("BOOT-INF");
this.mainClass = project.getObjects().property(String.class);
this.layered = project.getObjects().newInstance(LayeredSpec.class);
configureBootInfSpec(this.bootInfSpec);
getMainSpec().with(this.bootInfSpec);
project.getConfigurations().all((configuration) -> {

@ -35,6 +35,7 @@ import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.bundling.War;
import org.gradle.work.DisableCachingByDefault;
/**
* A custom {@link War} task that produces a Spring Boot executable war.
@ -43,6 +44,7 @@ import org.gradle.api.tasks.bundling.War;
* @author Phillip Webb
* @since 2.0.0
*/
@DisableCachingByDefault(because = "Not worth caching")
public class BootWar extends War implements BootArchive {
private static final String LAUNCHER = "org.springframework.boot.loader.WarLauncher";
@ -59,11 +61,11 @@ public class BootWar extends War implements BootArchive {
private final Property<String> mainClass;
private FileCollection providedClasspath;
private final ResolvedDependencies resolvedDependencies = new ResolvedDependencies();
private LayeredSpec layered = new LayeredSpec();
private final LayeredSpec layered;
private FileCollection providedClasspath;
/**
* Creates a new {@code BootWar} task.
@ -72,6 +74,7 @@ public class BootWar extends War implements BootArchive {
this.support = new BootArchiveSupport(LAUNCHER, new LibrarySpec(), new ZipCompressionResolver());
Project project = getProject();
this.mainClass = project.getObjects().property(String.class);
this.layered = project.getObjects().newInstance(LayeredSpec.class);
getWebInf().into("lib-provided", fromCallTo(this::getProvidedLibFiles));
this.support.moveModuleInfoToRoot(getRootSpec());
getRootSpec().eachFile(this.support::excludeNonZipLibraryFiles);

@ -16,11 +16,11 @@
package org.springframework.boot.gradle.tasks.bundling;
import groovy.lang.Closure;
import javax.inject.Inject;
import org.gradle.api.Action;
import org.gradle.api.GradleException;
import org.gradle.api.tasks.Input;
import org.gradle.util.ConfigureUtil;
import org.springframework.boot.buildpack.platform.build.Cache;
@ -34,7 +34,9 @@ public class CacheSpec {
private Cache cache = null;
CacheSpec() {
@Inject
public CacheSpec() {
}
public Cache asCache() {
@ -54,17 +56,6 @@ public class CacheSpec {
this.cache = Cache.volume(spec.getName());
}
/**
* Configures a volume cache using the given {@code closure}.
* @param closure the closure
*/
public void volume(Closure<?> closure) {
if (this.cache != null) {
throw new GradleException("Each image building cache can be configured only once");
}
volume(ConfigureUtil.configureUsing(closure));
}
/**
* Configuration for an image building cache stored in a Docker volume.
*/

@ -16,13 +16,11 @@
package org.springframework.boot.gradle.tasks.bundling;
import groovy.lang.Closure;
import org.gradle.api.Action;
import org.gradle.api.GradleException;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.Optional;
import org.gradle.util.ConfigureUtil;
import org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration;
@ -104,15 +102,6 @@ public class DockerSpec {
action.execute(this.builderRegistry);
}
/**
* Customizes the {@link DockerRegistrySpec} that configures authentication to the
* builder registry.
* @param closure the closure to apply
*/
public void builderRegistry(Closure<?> closure) {
builderRegistry(ConfigureUtil.configureUsing(closure));
}
/**
* Returns the {@link DockerRegistrySpec} that configures authentication to the
* publishing registry.
@ -132,15 +121,6 @@ public class DockerSpec {
action.execute(this.publishRegistry);
}
/**
* Customizes the {@link DockerRegistrySpec} that configures authentication to the
* publishing registry.
* @param closure the closure to apply
*/
public void publishRegistry(Closure<?> closure) {
publishRegistry(ConfigureUtil.configureUsing(closure));
}
/**
* Returns this configuration as a {@link DockerConfiguration} instance. This method
* should only be called when the configuration is complete and will no longer be

@ -23,11 +23,12 @@ import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import groovy.lang.Closure;
import javax.inject.Inject;
import org.gradle.api.Action;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Optional;
import org.gradle.util.ConfigureUtil;
import org.springframework.boot.loader.tools.Layer;
import org.springframework.boot.loader.tools.Layers;
@ -54,15 +55,21 @@ public class LayeredSpec {
private boolean enabled = true;
private ApplicationSpec application = new ApplicationSpec();
private ApplicationSpec application;
private DependenciesSpec dependencies = new DependenciesSpec();
private DependenciesSpec dependencies;
@Optional
private List<String> layerOrder;
private Layers layers;
@Inject
public LayeredSpec(ObjectFactory objects) {
this.application = objects.newInstance(ApplicationSpec.class);
this.dependencies = objects.newInstance(DependenciesSpec.class);
}
/**
* Returns whether the layer tools should be included as a dependency in the layered
* archive.
@ -128,14 +135,6 @@ public class LayeredSpec {
action.execute(this.application);
}
/**
* Customizes the {@link ApplicationSpec} using the given {@code closure}.
* @param closure the closure
*/
public void application(Closure<?> closure) {
application(ConfigureUtil.configureUsing(closure));
}
/**
* Returns the {@link DependenciesSpec} that controls the layers to which dependencies
* belong.
@ -163,14 +162,6 @@ public class LayeredSpec {
action.execute(this.dependencies);
}
/**
* Customizes the {@link DependenciesSpec} using the given {@code closure}.
* @param closure the closure
*/
public void dependencies(Closure<?> closure) {
dependencies(ConfigureUtil.configureUsing(closure));
}
/**
* Returns the order of the layers in the archive from least to most frequently
* changing.
@ -244,10 +235,6 @@ public class LayeredSpec {
this.intoLayers.add(this.specFactory.apply(layer));
}
public void intoLayer(String layer, Closure<?> closure) {
intoLayer(layer, ConfigureUtil.configureUsing(closure));
}
public void intoLayer(String layer, Action<IntoLayerSpec> action) {
IntoLayerSpec spec = this.specFactory.apply(layer);
action.execute(spec);
@ -385,6 +372,11 @@ public class LayeredSpec {
*/
public static class ApplicationSpec extends IntoLayersSpec {
@Inject
public ApplicationSpec() {
super(new IntoLayerSpecFactory());
}
/**
* Creates a new {@code ApplicationSpec} with the given {@code contents}.
* @param contents specs for the layers in which application content should be
@ -414,6 +406,11 @@ public class LayeredSpec {
*/
public static class DependenciesSpec extends IntoLayersSpec implements Serializable {
@Inject
public DependenciesSpec() {
super(new IntoLayerSpecFactory());
}
/**
* Creates a new {@code DependenciesSpec} with the given {@code contents}.
* @param contents specs for the layers in which dependencies should be included

@ -27,6 +27,7 @@ import org.gradle.api.tasks.JavaExec;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetOutput;
import org.gradle.jvm.toolchain.JavaLauncher;
import org.gradle.work.DisableCachingByDefault;
/**
* Custom {@link JavaExec} task for running a Spring Boot application.
@ -34,6 +35,7 @@ import org.gradle.jvm.toolchain.JavaLauncher;
* @author Andy Wilkinson
* @since 2.0.0
*/
@DisableCachingByDefault(because = "Application should always run")
public class BootRun extends JavaExec {
private boolean optimizedLaunch = true;

@ -17,8 +17,6 @@
package org.springframework.boot.gradle.docs;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.gradle.junit.GradleMultiDslExtension;
@ -37,14 +35,6 @@ class PublishingDocumentationTests {
GradleBuild gradleBuild;
@DisabledForJreRange(min = JRE.JAVA_16)
@TestTemplate
void mavenUpload() {
assertThat(this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("5.6")
.script("src/docs/gradle/publishing/maven").build("deployerRepository").getOutput())
.contains("https://repo.example.com");
}
@TestTemplate
void mavenPublish() {
assertThat(this.gradleBuild.script("src/docs/gradle/publishing/maven-publish").build("publishingConfiguration")

@ -68,7 +68,7 @@ public final class GradleProjectBuilder {
builder.withName(this.name);
}
if (JavaVersion.current() == JavaVersion.VERSION_17) {
NativeServices.initialize(userHome);
NativeServices.initializeOnClient(userHome);
try {
ProjectBuilderImpl.getGlobalServices();
}

@ -1,45 +0,0 @@
/*
* Copyright 2012-2021 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
*
* https://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.plugin;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
import org.springframework.boot.gradle.junit.GradleCompatibility;
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link MavenPluginAction}.
*
* @author Andy Wilkinson
*/
@DisabledForJreRange(min = JRE.JAVA_16)
@GradleCompatibility(versionsLessThan = "7.0-milestone-1")
class MavenPluginActionIntegrationTests {
GradleBuild gradleBuild;
@TestTemplate
void clearsConf2ScopeMappingsOfUploadBootArchivesTask() {
assertThat(this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("6.0.0").build("conf2ScopeMappings")
.getOutput()).contains("Conf2ScopeMappings = 0");
}
}

@ -1,74 +0,0 @@
/*
* Copyright 2012-2021 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
*
* https://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.tasks.bundling;
import java.io.File;
import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.TaskOutcome;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
import org.springframework.boot.gradle.junit.GradleCompatibility;
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for uploading Boot jars and wars using Gradle's Maven plugin.
*
* @author Andy Wilkinson
*/
@DisabledForJreRange(min = JRE.JAVA_16)
@GradleCompatibility(versionsLessThan = "7.0-milestone-1")
class MavenIntegrationTests {
GradleBuild gradleBuild;
@TestTemplate
void bootJarCanBeUploaded() {
BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("6.0.0")
.build("uploadBootArchives");
assertThat(result.task(":uploadBootArchives").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(artifactWithSuffix("jar")).isFile();
assertThat(artifactWithSuffix("pom")).is(pomWith().groupId("com.example")
.artifactId(this.gradleBuild.getProjectDir().getName()).version("1.0").noPackaging().noDependencies());
}
@TestTemplate
void bootWarCanBeUploaded() {
BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("6.0.0")
.build("uploadBootArchives");
assertThat(result.task(":uploadBootArchives").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(artifactWithSuffix("war")).isFile();
assertThat(artifactWithSuffix("pom"))
.is(pomWith().groupId("com.example").artifactId(this.gradleBuild.getProjectDir().getName())
.version("1.0").packaging("war").noDependencies());
}
private File artifactWithSuffix(String suffix) {
String name = this.gradleBuild.getProjectDir().getName();
return new File(new File(this.gradleBuild.getProjectDir(), "build/repo"),
String.format("com/example/%s/1.0/%s-1.0.%s", name, name, suffix));
}
private PomCondition pomWith() {
return new PomCondition();
}
}

@ -19,7 +19,6 @@ package org.springframework.boot.testsupport.gradle.testkit;
import java.util.Arrays;
import java.util.List;
import org.gradle.api.JavaVersion;
import org.gradle.util.GradleVersion;
/**
@ -33,31 +32,11 @@ public final class GradleVersions {
}
public static List<String> allCompatible() {
if (isJava17()) {
return Arrays.asList("7.2", "7.3");
}
if (isJava16()) {
return Arrays.asList("7.0.2", "7.1", "7.2", "7.3");
}
return Arrays.asList("6.8.3", GradleVersion.current().getVersion(), "7.0.2", "7.1.1", "7.2", "7.3");
return Arrays.asList(GradleVersion.current().getVersion());
}
public static String currentOrMinimumCompatible() {
if (isJava17()) {
return "7.2";
}
if (isJava16()) {
return "7.0.2";
}
return GradleVersion.current().getVersion();
}
private static boolean isJava17() {
return JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17);
}
private static boolean isJava16() {
return JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_16);
}
}

@ -50,7 +50,7 @@ task syncTestRepository(type: Sync) {
task antRun(type: JavaExec) {
dependsOn syncTestRepository, configurations.antDependencies
classpath = configurations.antDependencies;
main = "org.apache.tools.ant.launch.Launcher"
mainClass = "org.apache.tools.ant.launch.Launcher"
systemProperties = [
"ant-spring-boot.version" : version,
"projectDir": project.layout.projectDirectory

Loading…
Cancel
Save