Skip to content

Commit 05b4edf

Browse files
committed
Use ifeval block for Commercial/OSS documentation
See gh-42333
1 parent 7f8fe42 commit 05b4edf

File tree

10 files changed

+105
-9
lines changed

10 files changed

+105
-9
lines changed

buildSrc/src/main/java/org/springframework/boot/build/AsciidoctorConventions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.gradle.api.tasks.Sync;
3232

3333
import org.springframework.boot.build.artifacts.ArtifactRelease;
34+
import org.springframework.boot.build.properties.BuildProperties;
3435
import org.springframework.util.StringUtils;
3536

3637
/**
@@ -117,11 +118,14 @@ private void configureAsciidoctorTask(Project project, AbstractAsciidoctorTask a
117118
}
118119

119120
private void configureCommonAttributes(Project project, AbstractAsciidoctorTask asciidoctorTask) {
121+
String buildType = BuildProperties.get(project).buildType().toIdentifier();
120122
ArtifactRelease artifacts = ArtifactRelease.forProject(project);
121123
Map<String, Object> attributes = new HashMap<>();
122124
attributes.put("attribute-missing", "warn");
123125
attributes.put("github-tag", determineGitHubTag(project));
126+
attributes.put("build-type", buildType);
124127
attributes.put("artifact-release-type", artifacts.getType());
128+
attributes.put("build-and-artifact-release-type", buildType + "-" + artifacts.getType());
125129
attributes.put("artifact-download-repo", artifacts.getDownloadRepo());
126130
attributes.put("revnumber", project.getVersion());
127131
asciidoctorTask.attributes(attributes);

buildSrc/src/main/java/org/springframework/boot/build/properties/BuildType.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public enum BuildType {
3131
/**
3232
* A commercial build.
3333
*/
34-
COMMERCIAL
34+
COMMERCIAL;
35+
36+
public String toIdentifier() {
37+
return toString().replace("_", "").toLowerCase();
38+
}
3539

3640
}

spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/first-application.adoc

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,23 @@ Open your favorite text editor and add the following:
9595
9696
<!-- Additional lines to be added here... -->
9797
98-
ifeval::["{artifact-release-type}" != "release"]
99-
<!-- (you only need this if you are using a milestone or snapshot version) -->
98+
ifeval::["{build-and-artifact-release-type}" == "opensource-milestone"]
99+
<!-- (you don't need this if you are using a release version) -->
100+
<repositories>
101+
<repository>
102+
<id>spring-milestones</id>
103+
<url>https://repo.spring.io/milestone</url>
104+
</repository>
105+
</repositories>
106+
<pluginRepositories>
107+
<pluginRepository>
108+
<id>spring-milestones</id>
109+
<url>https://repo.spring.io/milestone</url>
110+
</pluginRepository>
111+
</pluginRepositories>
112+
endif::[]
113+
ifeval::["{build-and-artifact-release-type}" == "opensource-snapshot"]
114+
<!-- (you don't need this if you are using a release version) -->
100115
<repositories>
101116
<repository>
102117
<id>spring-snapshots</id>
@@ -122,7 +137,19 @@ endif::[]
122137
</project>
123138
----
124139

140+
ifeval::["{build-type}" == "opensource"]
125141
The preceding listing should give you a working build.
142+
endif::[]
143+
144+
ifeval::["{build-type}" == "commercial"]
145+
You will also have to configure your build to access the Spring Commercial repository.
146+
This is usual done through a local artifact repository that mirrors the content of the Spring Commercial repository.
147+
Alternatively, while it is not recommended, the Spring Commercial repository can also be accessed directly.
148+
In either case, see https://docs.vmware.com/en/Tanzu-Spring-Runtime/Commercial/Tanzu-Spring-Runtime/spring-enterprise-subscription.html[the Tanzu Spring Runtime documentation] for further details.
149+
150+
With the addition of the necessary repository configuration, the preceding listing should give you a working build.
151+
endif::[]
152+
126153
You can test it by running `mvn package` (for now, you can ignore the "`jar will be empty - no content was marked for inclusion!`" warning).
127154

128155
NOTE: At this point, you could import the project into an IDE (most modern Java IDEs include built-in support for Maven).

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,28 @@
22
= Getting Started
33
To get started with the plugin it needs to be applied to your project.
44

5-
ifeval::["{artifact-release-type}" == "release"]
5+
ifeval::["{build-type}" == "commercial"]
6+
The plugin is published to the Spring Commercial repository.
7+
You will have to configure your build to access this repository.
8+
This is usual done through a local artifact repository that mirrors the content of the Spring Commercial repository.
9+
Alternatively, while it is not recommended, the Spring Commercial repository can also be accessed directly.
10+
In either case, see https://docs.vmware.com/en/Tanzu-Spring-Runtime/Commercial/Tanzu-Spring-Runtime/spring-enterprise-subscription.html[the Tanzu Spring Runtime documentation] for further details.
11+
12+
With access to the Spring Commercial repository configured in `settings.gradle` or `settings.gradle.kts`, the plugin can be applied using the `plugins` block:
13+
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
14+
.Groovy
15+
----
16+
include::../gradle/getting-started/apply-plugin-commercial.gradle[]
17+
----
18+
19+
[source,kotlin,indent=0,subs="verbatim,attributes",role="secondary"]
20+
.Kotlin
21+
----
22+
include::../gradle/getting-started/apply-plugin-commercial.gradle.kts[]
23+
----
24+
endif::[]
25+
26+
ifeval::["{build-and-artifact-release-type}" == "opensource-release"]
627
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:
728
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
829
.Groovy
@@ -16,7 +37,8 @@ include::../gradle/getting-started/apply-plugin-release.gradle[]
1637
include::../gradle/getting-started/apply-plugin-release.gradle.kts[]
1738
----
1839
endif::[]
19-
ifeval::["{artifact-release-type}" == "milestone"]
40+
41+
ifeval::["{build-and-artifact-release-type}" == "opensource-milestone"]
2042
The plugin is published to the Spring milestones repository.
2143
Gradle can be configured to use the milestones repository and the plugin can then be applied using the `plugins` block.
2244
To configure Gradle to use the milestones repository, add the following to your `settings.gradle` (Groovy) or `settings.gradle.kts` (Kotlin):
@@ -47,7 +69,8 @@ include::../gradle/getting-started/apply-plugin-release.gradle[]
4769
include::../gradle/getting-started/apply-plugin-release.gradle.kts[]
4870
----
4971
endif::[]
50-
ifeval::["{artifact-release-type}" == "snapshot"]
72+
73+
ifeval::["{build-and-artifact-release-type}" == "opensource-snapshot"]
5174
The plugin is published to the Spring snapshots repository.
5275
Gradle can be configured to use the snapshots repository and the plugin can then be applied using the `plugins` block.
5376
To configure Gradle to use the snapshots repository, add the following to your `settings.gradle` (Groovy) or `settings.gradle.kts` (Kotlin):

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/managing-dependencies.adoc

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,21 @@ The `SpringBootPlugin` class provides a `BOM_COORDINATES` constant that can be u
5858

5959
First, configure the project to depend on the Spring Boot plugin but do not apply it:
6060

61-
ifeval::["{artifact-release-type}" == "release"]
61+
ifeval::["{build-type}" == "commercial"]
62+
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
63+
.Groovy
64+
----
65+
include::../gradle/managing-dependencies/depend-on-plugin-commercial.gradle[]
66+
----
67+
68+
[source,kotlin,indent=0,subs="verbatim,attributes",role="secondary"]
69+
.Kotlin
70+
----
71+
include::../gradle/managing-dependencies/depend-on-plugin-commercial.gradle.kts[]
72+
----
73+
endif::[]
74+
75+
ifeval::["{build-and-artifact-release-type}" == "opensource-release"]
6276
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
6377
.Groovy
6478
----
@@ -71,7 +85,8 @@ include::../gradle/managing-dependencies/depend-on-plugin-release.gradle[]
7185
include::../gradle/managing-dependencies/depend-on-plugin-release.gradle.kts[]
7286
----
7387
endif::[]
74-
ifeval::["{artifact-release-type}" == "milestone"]
88+
89+
ifeval::["{build-and-artifact-release-type}" == "opensource-milestone"]
7590
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
7691
.Groovy
7792
----
@@ -83,7 +98,8 @@ include::../gradle/managing-dependencies/depend-on-plugin-milestone.gradle[]
8398
include::../gradle/managing-dependencies/depend-on-plugin-release.gradle.kts[]
8499
----
85100
endif::[]
86-
ifeval::["{artifact-release-type}" == "snapshot"]
101+
102+
ifeval::["{build-and-artifact-release-type}" == "opensource-snapshot"]
87103
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
88104
.Groovy
89105
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins {
2+
id 'org.springframework.boot' version '{gradle-project-version}'
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins {
2+
id("org.springframework.boot") version "{gradle-project-version}"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins {
2+
id 'org.springframework.boot' version '{gradle-project-version}' apply false
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins {
2+
id("org.springframework.boot") version "{gradle-project-version}" apply false
3+
}

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/getting-started.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,19 @@ To use the Spring Boot Maven Plugin, include the appropriate XML in the `plugins
77
include::../maven/getting-started/pom.xml[tags=getting-started]
88
----
99

10+
ifeval::["{build-type}" == "commercial"]
11+
The plugin is published to the Spring Commercial repository.
12+
You will have to configure your build to access this repository.
13+
This is usually done through a local artifact repository that mirrors the content of the Spring Commercial repository.
14+
Alternatively, while it is not recommended, the Spring Commercial repository can also be accessed directly.
15+
In either case, see https://docs.vmware.com/en/Tanzu-Spring-Runtime/Commercial/Tanzu-Spring-Runtime/spring-enterprise-subscription.html[the Tanzu Spring Runtime documentation] for further details.
16+
endif::[]
17+
18+
ifeval::["{build-type}" == "opensource"]
1019
If you use a milestone or snapshot release, you also need to add the appropriate `pluginRepository` elements, as shown in the following listing:
1120

1221
[source,xml,indent=0,subs="verbatim,attributes",tabsize=4]
1322
----
1423
include::../maven/getting-started/plugin-repositories-pom.xml[tags=plugin-repositories]
1524
----
25+
endif::[]

0 commit comments

Comments
 (0)