Skip to content

Commit c4695b5

Browse files
committed
improvements after review
- make Gradle version compatibility clearer - fix non-documentation tests - revert explanations on applying the milestone and snapshot plugin on older gradle versions
1 parent 7f54a50 commit c4695b5

File tree

5 files changed

+55
-6
lines changed

5 files changed

+55
-6
lines changed

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/asciidoc/getting-started.adoc

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@ include::../gradle/getting-started/apply-plugin-release.gradle.kts[]
1919
----
2020
endif::[]
2121
ifeval::["{version-type}" == "MILESTONE"]
22-
The plugin is published to the Spring milestones repository and can be applied using the `plugins` block:
22+
The plugin is published to the Spring milestones repository.
23+
24+
For Gradle versions less than 4.10, you must apply the plugin imperatively:
25+
26+
[source,groovy,indent=0,subs="verbatim,attributes"]
27+
----
28+
include::../gradle/getting-started/apply-plugin-milestone.gradle[]
29+
----
30+
31+
For Gradle 4.10 and above, it can be applied using the `plugins` block:
2332
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
2433
.Groovy
2534
----
@@ -32,7 +41,7 @@ include::../gradle/getting-started/apply-plugin-release.gradle[]
3241
include::../gradle/getting-started/apply-plugin-release.gradle.kts[]
3342
----
3443

35-
with the following lines in the `settings.gradle` file (or `settings.gradle.kts` in Kotlin):
44+
provided you add the following lines in the `settings.gradle` file (or `settings.gradle.kts` in Kotlin):
3645

3746
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
3847
.Groovy
@@ -47,7 +56,16 @@ include::../gradle/getting-started/milestone-settings.gradle.kts[]
4756
----
4857
endif::[]
4958
ifeval::["{version-type}" == "SNAPSHOT"]
50-
The plugin is published to the Spring snapshots repository and can be applied using the `plugins` block:
59+
The plugin is published to the Spring snapshots repository.
60+
61+
For Gradle versions less than 4.10, you must apply the plugin imperatively:
62+
63+
[source,groovy,indent=0,subs="verbatim,attributes"]
64+
----
65+
include::../gradle/getting-started/apply-plugin-snapshot.gradle[]
66+
----
67+
68+
For Gradle 4.10 and above, it can be applied using the `plugins` block:
5169
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
5270
.Groovy
5371
----
@@ -60,7 +78,7 @@ include::../gradle/getting-started/apply-plugin-release.gradle[]
6078
include::../gradle/getting-started/apply-plugin-release.gradle.kts[]
6179
----
6280

63-
with the following lines in the `settings.gradle` file (or `settings.gradle.kts` in Kotlin):
81+
provided you add the following lines in the `settings.gradle` file (or `settings.gradle.kts` in Kotlin):
6482

6583
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
6684
.Groovy

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/asciidoc/index.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ Andy Wilkinson
3737
The Spring Boot Gradle Plugin provides Spring Boot support in https://gradle.org[Gradle],
3838
allowing you to package executable jar or war archives, run Spring Boot applications, and
3939
use the dependency management provided by `spring-boot-dependencies`. Spring Boot's
40-
Gradle plugin requires Gradle 4.4 or later.
40+
Gradle plugin requires Gradle 4.4 or later. If you choose to use the newer Kotlin DSL,
41+
it requires Gradle 4.10 or later.
4142

4243
In addition to this user guide, {api-documentation}[API documentation] is also available.
4344

@@ -47,4 +48,4 @@ include::packaging.adoc[]
4748
include::publishing.adoc[]
4849
include::running.adoc[]
4950
include::integrating-with-actuator.adoc[]
50-
include::reacting.adoc[]
51+
include::reacting.adoc[]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
buildscript {
2+
repositories {
3+
maven { url 'https://repo.spring.io/libs-milestone' }
4+
}
5+
6+
dependencies {
7+
classpath 'org.springframework.boot:spring-boot-gradle-plugin:{version}'
8+
}
9+
}
10+
11+
apply plugin: 'org.springframework.boot'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
buildscript {
2+
repositories {
3+
maven { url 'https://repo.spring.io/libs-snapshot' }
4+
}
5+
6+
dependencies {
7+
classpath 'org.springframework.boot:spring-boot-gradle-plugin:{version}'
8+
}
9+
}
10+
11+
apply plugin: 'org.springframework.boot'

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/GradleBuild.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.Arrays;
2626
import java.util.List;
2727
import java.util.regex.Pattern;
28+
import java.util.stream.Collectors;
2829

2930
import javax.xml.parsers.DocumentBuilderFactory;
3031
import javax.xml.xpath.XPath;
@@ -127,6 +128,11 @@ private List<File> pluginClasspath() {
127128
new File(pathOfJarContaining(ArchiveEntry.class)));
128129
}
129130

131+
private String pluginClasspathAsString() {
132+
return pluginClasspath().stream().map(File::getAbsolutePath)
133+
.collect(Collectors.joining(","));
134+
}
135+
130136
private String pathOfJarContaining(Class<?> type) {
131137
return type.getProtectionDomain().getCodeSource().getLocation().getPath();
132138
}
@@ -174,6 +180,8 @@ public GradleRunner prepareRunner(String... arguments) throws IOException {
174180
}
175181
List<String> allArguments = new ArrayList<>();
176182
allArguments.add("--stacktrace");
183+
allArguments.add("-PpluginClasspath=" + pluginClasspathAsString());
184+
allArguments.add("-PbootVersion=" + getBootVersion());
177185
allArguments.addAll(Arrays.asList(arguments));
178186
return gradleRunner.withArguments(allArguments);
179187
}

0 commit comments

Comments
 (0)