2017-03-15 04:51:23 +08:00
[[getting-started]]
2020-04-07 09:24:26 +08:00
== Getting Started
2017-03-15 04:51:23 +08:00
To get started with the plugin it needs to be applied to your project.
2020-06-02 00:47:42 +08:00
ifeval::["{spring-boot-artifactory-repo}" == "release"]
2019-09-09 17:59:49 +08:00
The plugin is https://plugins.gradle.org/plugin/org.springframework.boot[published to Gradle's plugin portal] and can be applied using the `plugins` block:
2018-09-23 04:39:36 +08:00
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
.Groovy
2017-03-15 04:51:23 +08:00
----
include::../gradle/getting-started/apply-plugin-release.gradle[]
----
2018-09-23 04:39:36 +08:00
[source,kotlin,indent=0,subs="verbatim,attributes",role="secondary"]
.Kotlin
----
include::../gradle/getting-started/apply-plugin-release.gradle.kts[]
----
2017-03-15 04:51:23 +08:00
endif::[]
2020-06-02 00:47:42 +08:00
ifeval::["{spring-boot-artifactory-repo}" == "milestone"]
2019-09-09 17:59:49 +08:00
The plugin is published to the Spring milestones repository.
2019-09-09 18:16:30 +08:00
Gradle can be configured to use the milestones repository and the plugin can then be applied using the `plugins` block.
2019-09-09 17:59:49 +08:00
To configure Gradle to use the milestones repository, add the following to your `settings.gradle` (Groovy) or `settings.gradle.kts` (Kotlin):
2018-10-05 17:40:45 +08:00
2018-09-23 04:39:36 +08:00
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
.Groovy
----
2018-10-05 17:40:45 +08:00
include::../gradle/getting-started/milestone-settings.gradle[]
2018-09-23 04:39:36 +08:00
----
[source,kotlin,indent=0,subs="verbatim,attributes",role="secondary"]
.Kotlin
----
2018-10-05 17:40:45 +08:00
include::../gradle/getting-started/milestone-settings.gradle.kts[]
2018-09-23 04:39:36 +08:00
----
2018-10-05 17:40:45 +08:00
The plugin can then be applied using the `plugins` block:
2018-09-23 04:39:36 +08:00
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
.Groovy
----
2018-10-05 17:40:45 +08:00
include::../gradle/getting-started/apply-plugin-release.gradle[]
2018-09-23 04:39:36 +08:00
----
[source,kotlin,indent=0,subs="verbatim,attributes",role="secondary"]
.Kotlin
----
2018-10-05 17:40:45 +08:00
include::../gradle/getting-started/apply-plugin-release.gradle.kts[]
2018-09-23 04:39:36 +08:00
----
2017-03-15 04:51:23 +08:00
endif::[]
2020-06-02 00:47:42 +08:00
ifeval::["{spring-boot-artifactory-repo}" == "snapshot"]
2019-09-09 17:59:49 +08:00
The plugin is published to the Spring snapshots repository.
2019-09-09 18:16:30 +08:00
Gradle can be configured to use the snapshots repository and the plugin can then be applied using the `plugins` block.
2019-09-09 17:59:49 +08:00
To configure Gradle to use the snapshots repository, add the following to your `settings.gradle` (Groovy) or `settings.gradle.kts` (Kotlin):
2018-10-05 17:40:45 +08:00
2018-09-23 04:39:36 +08:00
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
.Groovy
----
2018-10-05 17:40:45 +08:00
include::../gradle/getting-started/snapshot-settings.gradle[]
2018-09-23 04:39:36 +08:00
----
[source,kotlin,indent=0,subs="verbatim,attributes",role="secondary"]
.Kotlin
----
2018-10-05 17:40:45 +08:00
include::../gradle/getting-started/snapshot-settings.gradle.kts[]
2018-09-23 04:39:36 +08:00
----
2018-10-05 17:40:45 +08:00
The plugin can then be applied using the `plugins` block:
2018-09-23 04:39:36 +08:00
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
.Groovy
----
2018-10-05 17:40:45 +08:00
include::../gradle/getting-started/apply-plugin-release.gradle[]
2018-09-23 04:39:36 +08:00
----
[source,kotlin,indent=0,subs="verbatim,attributes",role="secondary"]
.Kotlin
----
2018-10-05 17:40:45 +08:00
include::../gradle/getting-started/apply-plugin-release.gradle.kts[]
2018-09-23 04:39:36 +08:00
----
2017-03-15 04:51:23 +08:00
endif::[]
2019-09-09 17:59:49 +08:00
Applied in isolation the plugin makes few changes to a project.
Instead, the plugin detects when certain other plugins are applied and reacts accordingly.
For example, when the `java` plugin is applied a task for building an executable jar is automatically configured.
2020-01-28 21:07:57 +08:00
A typical Spring Boot project will apply the {groovy-plugin}[`groovy`], {java-plugin}[`java`], or {kotlin-plugin}[`org.jetbrains.kotlin.jvm`] plugin and the {dependency-management-plugin}[`io.spring.dependency-management`] plugin as a minimum.
2019-09-09 17:59:49 +08:00
For example:
2017-03-15 04:51:23 +08:00
2018-09-23 04:39:36 +08:00
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
.Groovy
2017-03-15 04:51:23 +08:00
----
include::../gradle/getting-started/typical-plugins.gradle[tags=apply]
----
2018-09-23 04:39:36 +08:00
[source,kotlin,indent=0,subs="verbatim,attributes",role="secondary"]
.Kotlin
----
include::../gradle/getting-started/typical-plugins.gradle.kts[tags=apply]
----
2019-09-09 17:59:49 +08:00
To learn more about how the Spring Boot plugin behaves when other plugins are applied please see the section on <<reacting-to-other-plugins, reacting to other plugins>>.