Use ifeval block for Commercial/OSS documentation
See gh-42333
This commit is contained in:
@@ -31,6 +31,7 @@ import org.gradle.api.tasks.PathSensitivity;
|
||||
import org.gradle.api.tasks.Sync;
|
||||
|
||||
import org.springframework.boot.build.artifacts.ArtifactRelease;
|
||||
import org.springframework.boot.build.properties.BuildProperties;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -117,11 +118,14 @@ class AsciidoctorConventions {
|
||||
}
|
||||
|
||||
private void configureCommonAttributes(Project project, AbstractAsciidoctorTask asciidoctorTask) {
|
||||
String buildType = BuildProperties.get(project).buildType().toIdentifier();
|
||||
ArtifactRelease artifacts = ArtifactRelease.forProject(project);
|
||||
Map<String, Object> attributes = new HashMap<>();
|
||||
attributes.put("attribute-missing", "warn");
|
||||
attributes.put("github-tag", determineGitHubTag(project));
|
||||
attributes.put("build-type", buildType);
|
||||
attributes.put("artifact-release-type", artifacts.getType());
|
||||
attributes.put("build-and-artifact-release-type", buildType + "-" + artifacts.getType());
|
||||
attributes.put("artifact-download-repo", artifacts.getDownloadRepo());
|
||||
attributes.put("revnumber", project.getVersion());
|
||||
asciidoctorTask.attributes(attributes);
|
||||
|
||||
@@ -31,6 +31,10 @@ public enum BuildType {
|
||||
/**
|
||||
* A commercial build.
|
||||
*/
|
||||
COMMERCIAL
|
||||
COMMERCIAL;
|
||||
|
||||
public String toIdentifier() {
|
||||
return toString().replace("_", "").toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -95,8 +95,23 @@ Open your favorite text editor and add the following:
|
||||
|
||||
<!-- Additional lines to be added here... -->
|
||||
|
||||
ifeval::["{artifact-release-type}" != "release"]
|
||||
<!-- (you only need this if you are using a milestone or snapshot version) -->
|
||||
ifeval::["{build-and-artifact-release-type}" == "opensource-milestone"]
|
||||
<!-- (you don't need this if you are using a release version) -->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
endif::[]
|
||||
ifeval::["{build-and-artifact-release-type}" == "opensource-snapshot"]
|
||||
<!-- (you don't need this if you are using a release version) -->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
@@ -122,7 +137,19 @@ endif::[]
|
||||
</project>
|
||||
----
|
||||
|
||||
ifeval::["{build-type}" == "opensource"]
|
||||
The preceding listing should give you a working build.
|
||||
endif::[]
|
||||
|
||||
ifeval::["{build-type}" == "commercial"]
|
||||
You will also have to configure your build to access the Spring Commercial repository.
|
||||
This is usual done through a local artifact repository that mirrors the content of the Spring Commercial repository.
|
||||
Alternatively, while it is not recommended, the Spring Commercial repository can also be accessed directly.
|
||||
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.
|
||||
|
||||
With the addition of the necessary repository configuration, the preceding listing should give you a working build.
|
||||
endif::[]
|
||||
|
||||
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).
|
||||
|
||||
NOTE: At this point, you could import the project into an IDE (most modern Java IDEs include built-in support for Maven).
|
||||
|
||||
@@ -2,7 +2,28 @@
|
||||
= Getting Started
|
||||
To get started with the plugin it needs to be applied to your project.
|
||||
|
||||
ifeval::["{artifact-release-type}" == "release"]
|
||||
ifeval::["{build-type}" == "commercial"]
|
||||
The plugin is published to the Spring Commercial repository.
|
||||
You will have to configure your build to access this repository.
|
||||
This is usual done through a local artifact repository that mirrors the content of the Spring Commercial repository.
|
||||
Alternatively, while it is not recommended, the Spring Commercial repository can also be accessed directly.
|
||||
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.
|
||||
|
||||
With access to the Spring Commercial repository configured in `settings.gradle` or `settings.gradle.kts`, the plugin can be applied using the `plugins` block:
|
||||
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
|
||||
.Groovy
|
||||
----
|
||||
include::../gradle/getting-started/apply-plugin-commercial.gradle[]
|
||||
----
|
||||
|
||||
[source,kotlin,indent=0,subs="verbatim,attributes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
include::../gradle/getting-started/apply-plugin-commercial.gradle.kts[]
|
||||
----
|
||||
endif::[]
|
||||
|
||||
ifeval::["{build-and-artifact-release-type}" == "opensource-release"]
|
||||
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:
|
||||
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
|
||||
.Groovy
|
||||
@@ -16,7 +37,8 @@ include::../gradle/getting-started/apply-plugin-release.gradle[]
|
||||
include::../gradle/getting-started/apply-plugin-release.gradle.kts[]
|
||||
----
|
||||
endif::[]
|
||||
ifeval::["{artifact-release-type}" == "milestone"]
|
||||
|
||||
ifeval::["{build-and-artifact-release-type}" == "opensource-milestone"]
|
||||
The plugin is published to the Spring milestones repository.
|
||||
Gradle can be configured to use the milestones repository and the plugin can then be applied using the `plugins` block.
|
||||
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[]
|
||||
include::../gradle/getting-started/apply-plugin-release.gradle.kts[]
|
||||
----
|
||||
endif::[]
|
||||
ifeval::["{artifact-release-type}" == "snapshot"]
|
||||
|
||||
ifeval::["{build-and-artifact-release-type}" == "opensource-snapshot"]
|
||||
The plugin is published to the Spring snapshots repository.
|
||||
Gradle can be configured to use the snapshots repository and the plugin can then be applied using the `plugins` block.
|
||||
To configure Gradle to use the snapshots repository, add the following to your `settings.gradle` (Groovy) or `settings.gradle.kts` (Kotlin):
|
||||
|
||||
@@ -58,7 +58,21 @@ The `SpringBootPlugin` class provides a `BOM_COORDINATES` constant that can be u
|
||||
|
||||
First, configure the project to depend on the Spring Boot plugin but do not apply it:
|
||||
|
||||
ifeval::["{artifact-release-type}" == "release"]
|
||||
ifeval::["{build-type}" == "commercial"]
|
||||
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
|
||||
.Groovy
|
||||
----
|
||||
include::../gradle/managing-dependencies/depend-on-plugin-commercial.gradle[]
|
||||
----
|
||||
|
||||
[source,kotlin,indent=0,subs="verbatim,attributes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
include::../gradle/managing-dependencies/depend-on-plugin-commercial.gradle.kts[]
|
||||
----
|
||||
endif::[]
|
||||
|
||||
ifeval::["{build-and-artifact-release-type}" == "opensource-release"]
|
||||
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
|
||||
.Groovy
|
||||
----
|
||||
@@ -71,7 +85,8 @@ include::../gradle/managing-dependencies/depend-on-plugin-release.gradle[]
|
||||
include::../gradle/managing-dependencies/depend-on-plugin-release.gradle.kts[]
|
||||
----
|
||||
endif::[]
|
||||
ifeval::["{artifact-release-type}" == "milestone"]
|
||||
|
||||
ifeval::["{build-and-artifact-release-type}" == "opensource-milestone"]
|
||||
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
|
||||
.Groovy
|
||||
----
|
||||
@@ -83,7 +98,8 @@ include::../gradle/managing-dependencies/depend-on-plugin-milestone.gradle[]
|
||||
include::../gradle/managing-dependencies/depend-on-plugin-release.gradle.kts[]
|
||||
----
|
||||
endif::[]
|
||||
ifeval::["{artifact-release-type}" == "snapshot"]
|
||||
|
||||
ifeval::["{build-and-artifact-release-type}" == "opensource-snapshot"]
|
||||
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
|
||||
.Groovy
|
||||
----
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '{gradle-project-version}'
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
plugins {
|
||||
id("org.springframework.boot") version "{gradle-project-version}"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '{gradle-project-version}' apply false
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
plugins {
|
||||
id("org.springframework.boot") version "{gradle-project-version}" apply false
|
||||
}
|
||||
@@ -7,9 +7,19 @@ To use the Spring Boot Maven Plugin, include the appropriate XML in the `plugins
|
||||
include::../maven/getting-started/pom.xml[tags=getting-started]
|
||||
----
|
||||
|
||||
ifeval::["{build-type}" == "commercial"]
|
||||
The plugin is published to the Spring Commercial repository.
|
||||
You will have to configure your build to access this repository.
|
||||
This is usually done through a local artifact repository that mirrors the content of the Spring Commercial repository.
|
||||
Alternatively, while it is not recommended, the Spring Commercial repository can also be accessed directly.
|
||||
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.
|
||||
endif::[]
|
||||
|
||||
ifeval::["{build-type}" == "opensource"]
|
||||
If you use a milestone or snapshot release, you also need to add the appropriate `pluginRepository` elements, as shown in the following listing:
|
||||
|
||||
[source,xml,indent=0,subs="verbatim,attributes",tabsize=4]
|
||||
----
|
||||
include::../maven/getting-started/plugin-repositories-pom.xml[tags=plugin-repositories]
|
||||
----
|
||||
endif::[]
|
||||
|
||||
Reference in New Issue
Block a user