For the latest stable version, please use Spring Boot 3.4.1! |
Reacting to Other Plugins
When another plugin is applied the Spring Boot plugin reacts by making various changes to the project’s configuration. This section describes those changes.
Reacting to the Java Plugin
When Gradle’s java
plugin is applied to a project, the Spring Boot plugin:
-
Creates a
BootJar
task namedbootJar
that will create an executable, uber jar for the project. The jar will contain everything on the runtime classpath of the main source set; classes are packaged inBOOT-INF/classes
and jars are packaged inBOOT-INF/lib
-
Configures the
assemble
task to depend on thebootJar
task. -
Configures the
jar
task to useplain
as the convention for its archive classifier. -
Creates a
BootBuildImage
task namedbootBuildImage
that will create a OCI image using a buildpack. -
Creates a
BootRun
task namedbootRun
that can be used to run your application using themain
source set to find its main method and provide its runtime classpath. -
Creates a
BootRun
task namedbootTestRun
that can be used to run your application using thetest
source set to find its main method and provide its runtime classpath. -
Creates a configuration named
bootArchives
that contains the artifact produced by thebootJar
task. -
Creates a configuration named
developmentOnly
for dependencies that are only required at development time, such as Spring Boot’s Devtools, and should not be packaged in executable jars and wars. -
Creates a configuration named
testAndDevelopmentOnly
for dependencies that are only required at development time and when writing and running tests and that should not be packaged in executable jars and wars. -
Creates a configuration named
productionRuntimeClasspath
. It is equivalent toruntimeClasspath
minus any dependencies that only appear in thedevelopmentOnly
ortestDevelopmentOnly
configurations. -
Configures any
JavaCompile
tasks with no configured encoding to useUTF-8
. -
Configures any
JavaCompile
tasks to use the-parameters
compiler argument.
Reacting to the Kotlin Plugin
When Kotlin’s Gradle plugin is applied to a project, the Spring Boot plugin:
-
Aligns the Kotlin version used in Spring Boot’s dependency management with the version of the plugin. This is achieved by setting the
kotlin.version
property with a value that matches the version of the Kotlin plugin. -
Configures any
KotlinCompile
tasks to use the-java-parameters
compiler argument.
Reacting to the War Plugin
When Gradle’s war
plugin is applied to a project, the Spring Boot plugin:
-
Creates a
BootWar
task namedbootWar
that will create an executable, fat war for the project. In addition to the standard packaging, everything in theprovidedRuntime
configuration will be packaged inWEB-INF/lib-provided
. -
Configures the
assemble
task to depend on thebootWar
task. -
Configures the
war
task to useplain
as the convention for its archive classifier. -
Configures the
bootArchives
configuration to contain the artifact produced by thebootWar
task.
Reacting to the Dependency Management Plugin
When the io.spring.dependency-management
plugin is applied to a project, the Spring Boot plugin will automatically import the spring-boot-dependencies
bom.
Reacting to the Application Plugin
When Gradle’s application
plugin is applied to a project, the Spring Boot plugin:
-
Creates a
CreateStartScripts
task namedbootStartScripts
that will create scripts that launch the artifact in thebootArchives
configuration usingjava -jar
. The task is configured to use theapplicationDefaultJvmArgs
property as a convention for itsdefaultJvmOpts
property. -
Creates a new distribution named
boot
and configures it to contain the artifact in thebootArchives
configuration in itslib
directory and the start scripts in itsbin
directory. -
Configures the
bootRun
task to use themainClassName
property as a convention for itsmain
property. -
Configures the
bootRun
andbootTestRun
tasks to use theapplicationDefaultJvmArgs
property as a convention for theirjvmArgs
property. -
Configures the
bootJar
task to use themainClassName
property as a convention for theStart-Class
entry in its manifest. -
Configures the
bootWar
task to use themainClassName
property as a convention for theStart-Class
entry in its manifest.
Reacting to the GraalVM Native Image Plugin
When the GraalVM Native Image plugin is applied to a project, the Spring Boot plugin:
-
Applies the
org.springframework.boot.aot
plugin that:-
Registers
aot
andaotTest
source sets. -
Registers a
ProcessAot
task namedprocessAot
that will generate AOT-optimized source for the application in theaot
source set. -
Configures the Java compilation and process resources tasks for the
aot
source set to depend uponprocessAot
. -
Registers a
ProcessTestAot
task namedprocessTestAot
that will generated AOT-optimized source for the application’s tests in theaotTest
source set. -
Configures the Java compilation and process resources tasks for the
aotTest
source set to depend uponprocessTestAot
.
-
-
Adds the output of the
aot
source set to the classpath of themain
GraalVM native binary. -
Adds the output of the
aotTest
source set to the classpath of thetest
GraalVM native binary. -
Configures the GraalVM extension to disable Toolchain detection.
-
Configures each GraalVM native binary to require GraalVM 22.3 or later.
-
Configures the
bootJar
task to include the reachability metadata produced by thecollectReachabilityMetadata
task in its jar. -
Configures the
bootBuildImage
task to usepaketobuildpacks/builder-jammy-tiny:latest
as its builder and to setBP_NATIVE_IMAGE
totrue
in its environment.
Reacting to the CycloneDX Plugin
When the CycloneDX plugin is applied to a project, the Spring Boot plugin:
-
Configures the
cyclonedxBom
task to use theapplication
project type and output the SBOM to theapplication.cdx
file in JSON format without full license texts. -
Adds the SBOM under
META-INF/sbom
in the generated jar or war file. -
Adds the
Sbom-Format
andSbom-Location
to the manifest of the jar or war file.