Skip to content

Commit eee7e41

Browse files
committed
Add section on 'Gradle Dependency Management' under the 'Using Spring Boot for Apache Geode' section of the reference documentation.
1 parent 6044bc9 commit eee7e41

File tree

1 file changed

+85
-10
lines changed

1 file changed

+85
-10
lines changed

spring-geode-docs/src/docs/asciidoc/index.adoc

Lines changed: 85 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ John Blum
4646
:spring-data-geode-javadoc: https://docs.spring.io/spring-data/geode/docs/current/api
4747
:spring-data-geode-website: https://spring.io/projects/spring-data-geode
4848
:spring-data-website: https://spring.io/projects/spring-data
49+
:spring-dependency-management-gradle-plugin-version: 1.0.10.RELEASE
4950
:spring-framework-docs: https://docs.spring.io/spring/docs/current/spring-framework-reference
5051
:spring-framework-javadoc: https://docs.spring.io/spring/docs/current/javadoc-api
5152
:spring-framework-website: https://spring.io/projects/spring-framework
@@ -147,7 +148,8 @@ to see Spring Boot for {apache-geode-name} in action!
147148
[[maven-gradle]]
148149
== Using Spring Boot for {apache-geode-name}
149150

150-
To use Spring Boot for {apache-geode-name}, simply declare the `spring-geode-starter` on your application classpath:
151+
To use Spring Boot for {apache-geode-name}, simply declare the `spring-geode-starter` on your Spring Boot application
152+
classpath:
151153

152154
.Maven
153155
[source,xml]
@@ -163,7 +165,7 @@ To use Spring Boot for {apache-geode-name}, simply declare the `spring-geode-sta
163165
----
164166

165167
.Gradle
166-
[source,java]
168+
[source,groovy]
167169
[subs="verbatim,attributes"]
168170
----
169171
dependencies {
@@ -174,7 +176,7 @@ dependencies {
174176
TIP: To use {pivotal-gemfire-name} in place of {apache-geode-name}, simply change the `artifactId` from `spring-geode-starter`
175177
to `spring-gemfire-starter`.
176178

177-
[[maven-gradle-bom]]
179+
[[maven-bom]]
178180
=== Maven BOM
179181

180182
If you anticipate using more than 1 Spring Boot for {apache-geode-name} (SBDG) module in your Spring Boot application,
@@ -183,7 +185,7 @@ then you can also use the new `org.springframework.geode:spring-geode-bom` Maven
183185
Your application use case(s) may require more than 1 module if, for example, you need (HTTP) Session state management
184186
and replication (e.g. `spring-geode-starter-session`), or you need to enable Spring Boot Actuator endpoints for
185187
{apache-geode-name} (e.g. `spring-geode-starter-actuator`), or perhaps you need assistance writing complex Unit
186-
and distributed Integration Tests using STDG (e.g. `spring-geode-starter-test`).
188+
and (distributed) Integration Tests using Spring Test for Apache Geode (STDG) (e.g. `spring-geode-starter-test`).
187189

188190
You can declare (include) and use any 1 of the SBDG modules:
189191

@@ -252,25 +254,98 @@ might appear as follows:
252254

253255
Notice that 1) the Spring Boot application Maven POM (`pom.xml`) contains a `<dependencyManagement>` section declaring
254256
the `org.springframework.geode:spring-geode-bom` and that 2) none of the `spring-geode-starter[-xyz]` dependencies
255-
specify an explicit `<version>`, which is 3) managed by the `spring-geode.version` property making it easy to switch
256-
between versions of SBDG as needed.
257+
explicitly specify a `<version>`, which is 3) managed by the `spring-geode.version` property making it easy to switch
258+
between versions of SBDG as needed, applied evenly to all the SBDG modules declared and used in your application Maven
259+
POM.
257260

258261
If you change the version of SBDG, make sure to change the `org.springframework.boot:spring-boot-starter-parent` POM
259262
version to match. SBDG is always 1 `major` version behind, but matches on `minor` version and `patch` version
260263
(and `version qualifier`, e.g. `SNAPSHOT`, `M#`, `RC#`, or `RELEASE`, if applicable).
261264

262265
For example, SBDG `1.4.0` is based on Spring Boot `2.4.0`. SBDG `1.3.5.RELEASE` is based on
263-
Spring Boot `2.3.5.RELEASE`. It is important that the versions align.
266+
Spring Boot `2.3.5.RELEASE` and so on. It is important that the versions align.
264267

265-
Of course, all of these concerns are easy to do by simply going to https://start.spring.io[start.spring.io]
266-
and adding the "_Spring for {apache-geode-name}_" dependency.
268+
Of course, all of these concerns are easy to do and handled for you by simply going to
269+
https://start.spring.io[start.spring.io] and adding the "_Spring for {apache-geode-name}_" dependency.
267270

268271
Clink on this https://start.spring.io/#!platformVersion={spring-boot-version}&dependencies=geode[link]
269272
to get started!
270273

274+
[[gradle-dependency-management]]
275+
=== Gradle Dependency Management
276+
277+
The user experience when using Gradle is similar to that of Maven.
278+
279+
Again, if you will be declaring and using more than 1 SBDG module in your Spring Boot application, for example,
280+
the `spring-geode-starter` along with the `spring-geode-starter-actuator` dependency, then using the `spring-geode-bom`
281+
inside your application Gradle build file will help.
282+
283+
Your application Gradle build file configuration will roughly appear as follows:
284+
285+
.Spring Boot application Gradle build file
286+
[source,groovy]
287+
[subs="verbatim,attributes"]
288+
----
289+
plugins {
290+
id 'org.springframework.boot' version '{spring-boot-version}'
291+
id 'io.spring.dependency-management' version '{spring-dependency-management-gradle-plugin-version}'
292+
id 'java'
293+
}
294+
295+
// ...
296+
297+
ext {
298+
set('springGeodeVersion', "{spring-boot-data-geode-version}")
299+
}
300+
301+
dependencies {
302+
implementation 'org.springframework.geode:spring-geode-starter'
303+
implementation 'org.springframework.geode:spring-geode-starter-actuator'
304+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
305+
}
306+
307+
dependencyManagement {
308+
imports {
309+
mavenBom "org.springframework.geode:spring-geode-bom:$\{springGeodeVersion\}"
310+
}
311+
}
312+
----
313+
314+
A combination of the {spring-boot-docs-html}/using-spring-boot.html#using-boot-gradle[Spring Boot Gradle Plugin]
315+
and the https://github.com/spring-gradle-plugins/dependency-management-plugin[Spring Dependency Management Gradle Plugin]
316+
manage the application dependencies for you.
317+
318+
In a nutshell, the _Spring Dependency Management Gradle Plugin_ provides dependency management capabilities for Gradle
319+
much like Maven. The _Spring Boot Gradle Plugin_ defines a curated and tested set of versions for many 3rd party Java
320+
libraries. Together they make adding dependencies and managing (compatible) versions easier!
321+
322+
Again, you don't need to explicitly declare the version when adding a dependency, including a new SBDG module dependency
323+
(e.g. `spring-geode-starter-session`) since this has already been determined for you. You can simply declare the
324+
dependency:
325+
326+
[source,groovy]
327+
----
328+
implementation 'org.springframework.geode:spring-geode-starter-session'
329+
----
330+
331+
The version of SBDG is controlled by the extension property (`springGeodeVersion`) in the application Gradle build file.
332+
333+
To use a different version of SBDG, simply set the `springGeodeVersion` property to the desired version
334+
(e.g. `1.3.5.RELEASE`). Of course, make sure the version of Spring Boot matches!
335+
336+
SBDG is always 1 `major` version behind, but matches on `minor` version and `patch` version (and `version qualifier`,
337+
e.g. `SNAPSHOT`, `M#`, `RC#`, or `RELEASE`, if applicable). For example, SBDG `1.4.0` is based on Spring Boot `2.4.0`.
338+
SBDG `1.3.5.RELEASE` is based on Spring Boot `2.3.5.RELEASE` and so on. It is important that the versions align.
339+
340+
Of course, all of these concerns are easy to do and handled for you by simply going to
341+
https://start.spring.io[start.spring.io] and adding the "_Spring for {apache-geode-name}_" dependency.
342+
343+
Clink on this https://start.spring.io/#!type=gradle-project&platformVersion={spring-boot-version}&dependencies=geode[link]
344+
to get started!
345+
271346
ifeval::["{version-snapshot}" == "true"]
272347
[[maven-gradle-repository]]
273-
=== Repository declaration
348+
=== Repository Declaration
274349

275350
Since you are using a `SNAPSHOT` version, you need to add the Spring Snapshot Maven Repository.
276351

0 commit comments

Comments
 (0)