Skip to content

Commit ec615f6

Browse files
committed
Merge branch '3.2.x' into 3.3.x
2 parents 2bb34e4 + 05b4edf commit ec615f6

File tree

11 files changed

+213
-61
lines changed

11 files changed

+213
-61
lines changed

buildSrc/src/main/java/org/springframework/boot/build/antora/AntoraAsciidocAttributes.java

+15-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import org.springframework.boot.build.artifacts.ArtifactRelease;
3333
import org.springframework.boot.build.bom.BomExtension;
3434
import org.springframework.boot.build.bom.Library;
35+
import org.springframework.boot.build.properties.BuildProperties;
36+
import org.springframework.boot.build.properties.BuildType;
3537
import org.springframework.util.Assert;
3638

3739
/**
@@ -47,6 +49,8 @@ public class AntoraAsciidocAttributes {
4749

4850
private final boolean latestVersion;
4951

52+
private final BuildType buildType;
53+
5054
private final ArtifactRelease artifactRelease;
5155

5256
private final List<Library> libraries;
@@ -59,16 +63,18 @@ public AntoraAsciidocAttributes(Project project, BomExtension dependencyBom,
5963
Map<String, String> dependencyVersions) {
6064
this.version = String.valueOf(project.getVersion());
6165
this.latestVersion = Boolean.parseBoolean(String.valueOf(project.findProperty("latestVersion")));
66+
this.buildType = BuildProperties.get(project).buildType();
6267
this.artifactRelease = ArtifactRelease.forProject(project);
6368
this.libraries = dependencyBom.getLibraries();
6469
this.dependencyVersions = dependencyVersions;
6570
this.projectProperties = project.getProperties();
6671
}
6772

68-
AntoraAsciidocAttributes(String version, boolean latestVersion, List<Library> libraries,
73+
AntoraAsciidocAttributes(String version, boolean latestVersion, BuildType buildType, List<Library> libraries,
6974
Map<String, String> dependencyVersions, Map<String, ?> projectProperties) {
7075
this.version = version;
7176
this.latestVersion = latestVersion;
77+
this.buildType = buildType;
7278
this.artifactRelease = ArtifactRelease.forVersion(version);
7379
this.libraries = (libraries != null) ? libraries : Collections.emptyList();
7480
this.dependencyVersions = (dependencyVersions != null) ? dependencyVersions : Collections.emptyMap();
@@ -77,6 +83,7 @@ public AntoraAsciidocAttributes(Project project, BomExtension dependencyBom,
7783

7884
public Map<String, String> get() {
7985
Map<String, String> attributes = new LinkedHashMap<>();
86+
addBuildTypeAttribute(attributes);
8087
addGitHubAttributes(attributes);
8188
addVersionAttributes(attributes);
8289
addArtifactAttributes(attributes);
@@ -86,6 +93,10 @@ public Map<String, String> get() {
8693
return attributes;
8794
}
8895

96+
private void addBuildTypeAttribute(Map<String, String> attributes) {
97+
attributes.put("build-type", this.buildType.toIdentifier());
98+
}
99+
89100
private void addGitHubAttributes(Map<String, String> attributes) {
90101
attributes.put("github-repo", "spring-projects/spring-boot");
91102
attributes.put("github-ref", determineGitHubRef());
@@ -152,6 +163,8 @@ private String getVersion(String groupAndArtifactId) {
152163
private void addArtifactAttributes(Map<String, String> attributes) {
153164
attributes.put("url-artifact-repository", this.artifactRelease.getDownloadRepo());
154165
attributes.put("artifact-release-type", this.artifactRelease.getType());
166+
attributes.put("build-and-artifact-release-type",
167+
this.buildType.toIdentifier() + "-" + this.artifactRelease.getType());
155168
}
156169

157170
private void addUrlJava(Map<String, String> attributes) {
@@ -177,8 +190,7 @@ public synchronized Object put(Object key, Object value) {
177190
};
178191
try (InputStream in = getClass().getResourceAsStream("antora-asciidoc-attributes.properties")) {
179192
properties.load(in);
180-
}
181-
catch (IOException ex) {
193+
} catch (IOException ex) {
182194
throw new UncheckedIOException(ex);
183195
}
184196
}

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

+5-1
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
}

buildSrc/src/test/java/org/springframework/boot/build/antora/AntoraAsciidocAttributesTests.java

+70-28
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.springframework.boot.build.bom.Library.ProhibitedVersion;
3232
import org.springframework.boot.build.bom.Library.VersionAlignment;
3333
import org.springframework.boot.build.bom.bomr.version.DependencyVersion;
34+
import org.springframework.boot.build.properties.BuildType;
3435

3536
import static org.assertj.core.api.Assertions.assertThat;
3637

@@ -42,105 +43,146 @@
4243
*/
4344
class AntoraAsciidocAttributesTests {
4445

46+
@Test
47+
void buildTypeWhenOpenSource() {
48+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, BuildType.OPEN_SOURCE, null,
49+
mockDependencyVersions(), null);
50+
assertThat(attributes.get()).containsEntry("build-type", "opensource");
51+
}
52+
53+
@Test
54+
void buildTypeWhenCommercial() {
55+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, BuildType.COMMERCIAL, null,
56+
mockDependencyVersions(), null);
57+
assertThat(attributes.get()).containsEntry("build-type", "commercial");
58+
}
59+
4560
@Test
4661
void githubRefWhenReleasedVersionIsTag() {
47-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, null,
62+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, BuildType.OPEN_SOURCE, null,
4863
mockDependencyVersions(), null);
4964
assertThat(attributes.get()).containsEntry("github-ref", "v1.2.3");
5065
}
5166

5267
@Test
5368
void githubRefWhenLatestSnapshotVersionIsMainBranch() {
54-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3-SNAPSHOT", true, null,
55-
mockDependencyVersions(), null);
69+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3-SNAPSHOT", true,
70+
BuildType.OPEN_SOURCE, null, mockDependencyVersions(), null);
5671
assertThat(attributes.get()).containsEntry("github-ref", "main");
5772
}
5873

5974
@Test
6075
void githubRefWhenOlderSnapshotVersionIsBranch() {
61-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3-SNAPSHOT", false, null,
62-
mockDependencyVersions(), null);
76+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3-SNAPSHOT", false,
77+
BuildType.OPEN_SOURCE, null, mockDependencyVersions(), null);
6378
assertThat(attributes.get()).containsEntry("github-ref", "1.2.x");
6479
}
6580

6681
@Test
6782
void githubRefWhenOlderSnapshotHotFixVersionIsBranch() {
68-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3.1-SNAPSHOT", false, null,
69-
mockDependencyVersions(), null);
83+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3.1-SNAPSHOT", false,
84+
BuildType.OPEN_SOURCE, null, mockDependencyVersions(), null);
7085
assertThat(attributes.get()).containsEntry("github-ref", "1.2.3.x");
7186
}
7287

7388
@Test
7489
void versionReferenceFromLibrary() {
7590
Library library = mockLibrary(Collections.emptyMap());
76-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3.1-SNAPSHOT", false, List.of(library),
77-
mockDependencyVersions(), null);
91+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3.1-SNAPSHOT", false,
92+
BuildType.OPEN_SOURCE, List.of(library), mockDependencyVersions(), null);
7893
assertThat(attributes.get()).containsEntry("version-spring-framework", "1.2.3");
7994
}
8095

8196
@Test
8297
void versionReferenceFromSpringDataDependencyReleaseVersion() {
83-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, null,
98+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, BuildType.OPEN_SOURCE, null,
8499
mockDependencyVersions("3.2.5"), null);
85100
assertThat(attributes.get()).containsEntry("version-spring-data-mongodb-docs", "3.2");
86101
assertThat(attributes.get()).containsEntry("version-spring-data-mongodb-javadoc", "3.2.x");
87102
}
88103

89104
@Test
90105
void versionReferenceFromSpringDataDependencySnapshotVersion() {
91-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, null,
106+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, BuildType.OPEN_SOURCE, null,
92107
mockDependencyVersions("3.2.0-SNAPSHOT"), null);
93108
assertThat(attributes.get()).containsEntry("version-spring-data-mongodb-docs", "3.2-SNAPSHOT");
94109
assertThat(attributes.get()).containsEntry("version-spring-data-mongodb-javadoc", "3.2.x");
95110
}
96111

97112
@Test
98113
void versionNativeBuildTools() {
99-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, null,
114+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, BuildType.OPEN_SOURCE, null,
100115
mockDependencyVersions(), Map.of("nativeBuildToolsVersion", "3.4.5"));
101116
assertThat(attributes.get()).containsEntry("version-native-build-tools", "3.4.5");
102117
}
103118

104119
@Test
105120
void urlArtifactRepositoryWhenRelease() {
106-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, null,
121+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, BuildType.OPEN_SOURCE, null,
107122
mockDependencyVersions(), null);
108123
assertThat(attributes.get()).containsEntry("url-artifact-repository", "https://repo.maven.apache.org/maven2");
109124
}
110125

111126
@Test
112127
void urlArtifactRepositoryWhenMilestone() {
113-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3-M1", true, null,
114-
mockDependencyVersions(), null);
128+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3-M1", true, BuildType.OPEN_SOURCE,
129+
null, mockDependencyVersions(), null);
115130
assertThat(attributes.get()).containsEntry("url-artifact-repository", "https://repo.spring.io/milestone");
116131
}
117132

118133
@Test
119134
void urlArtifactRepositoryWhenSnapshot() {
120-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3-SNAPSHOT", true, null,
121-
mockDependencyVersions(), null);
135+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3-SNAPSHOT", true,
136+
BuildType.OPEN_SOURCE, null, mockDependencyVersions(), null);
122137
assertThat(attributes.get()).containsEntry("url-artifact-repository", "https://repo.spring.io/snapshot");
123138
}
124139

125140
@Test
126-
void artifactReleaseTypeWhenRelease() {
127-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, null,
141+
void artifactReleaseTypeWhenOpenSourceRelease() {
142+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, BuildType.OPEN_SOURCE, null,
128143
mockDependencyVersions(), null);
129144
assertThat(attributes.get()).containsEntry("artifact-release-type", "release");
145+
assertThat(attributes.get()).containsEntry("build-and-artifact-release-type", "opensource-release");
130146
}
131147

132148
@Test
133-
void artifactReleaseTypeWhenMilestone() {
134-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3-M1", true, null,
135-
mockDependencyVersions(), null);
149+
void artifactReleaseTypeWhenOpenSourceMilestone() {
150+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3-M1", true, BuildType.OPEN_SOURCE,
151+
null, mockDependencyVersions(), null);
136152
assertThat(attributes.get()).containsEntry("artifact-release-type", "milestone");
153+
assertThat(attributes.get()).containsEntry("build-and-artifact-release-type", "opensource-milestone");
137154
}
138155

139156
@Test
140-
void artifactReleaseTypeWhenSnapshot() {
141-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3-SNAPSHOT", true, null,
157+
void artifactReleaseTypeWhenOpenSourceSnapshot() {
158+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3-SNAPSHOT", true,
159+
BuildType.OPEN_SOURCE, null, mockDependencyVersions(), null);
160+
assertThat(attributes.get()).containsEntry("artifact-release-type", "snapshot");
161+
assertThat(attributes.get()).containsEntry("build-and-artifact-release-type", "opensource-snapshot");
162+
}
163+
164+
@Test
165+
void artifactReleaseTypeWhenCommercialRelease() {
166+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3", true, BuildType.COMMERCIAL, null,
167+
mockDependencyVersions(), null);
168+
assertThat(attributes.get()).containsEntry("artifact-release-type", "release");
169+
assertThat(attributes.get()).containsEntry("build-and-artifact-release-type", "commercial-release");
170+
}
171+
172+
@Test
173+
void artifactReleaseTypeWhenCommercialMilestone() {
174+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3-M1", true, BuildType.COMMERCIAL, null,
142175
mockDependencyVersions(), null);
176+
assertThat(attributes.get()).containsEntry("artifact-release-type", "milestone");
177+
assertThat(attributes.get()).containsEntry("build-and-artifact-release-type", "commercial-milestone");
178+
}
179+
180+
@Test
181+
void artifactReleaseTypeWhenCommercialSnapshot() {
182+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3-SNAPSHOT", true, BuildType.COMMERCIAL,
183+
null, mockDependencyVersions(), null);
143184
assertThat(attributes.get()).containsEntry("artifact-release-type", "snapshot");
185+
assertThat(attributes.get()).containsEntry("build-and-artifact-release-type", "commercial-snapshot");
144186
}
145187

146188
@Test
@@ -149,16 +191,16 @@ void urlLinksFromLibrary() {
149191
links.put("site", (version) -> "https://example.com/site/" + version);
150192
links.put("docs", (version) -> "https://example.com/docs/" + version);
151193
Library library = mockLibrary(links);
152-
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3.1-SNAPSHOT", false, List.of(library),
153-
mockDependencyVersions(), null);
194+
AntoraAsciidocAttributes attributes = new AntoraAsciidocAttributes("1.2.3.1-SNAPSHOT", false,
195+
BuildType.OPEN_SOURCE, List.of(library), mockDependencyVersions(), null);
154196
assertThat(attributes.get()).containsEntry("url-spring-framework-site", "https://example.com/site/1.2.3")
155197
.containsEntry("url-spring-framework-docs", "https://example.com/docs/1.2.3");
156198
}
157199

158200
@Test
159201
void linksFromProperties() {
160-
Map<String, String> attributes = new AntoraAsciidocAttributes("1.2.3-SNAPSHOT", true, null,
161-
mockDependencyVersions(), null)
202+
Map<String, String> attributes = new AntoraAsciidocAttributes("1.2.3-SNAPSHOT", true, BuildType.OPEN_SOURCE,
203+
null, mockDependencyVersions(), null)
162204
.get();
163205
assertThat(attributes).containsEntry("include-java", "ROOT:example$java/org/springframework/boot/docs");
164206
assertThat(attributes).containsEntry("url-spring-data-cassandra-site",

spring-boot-project/spring-boot-docs/src/docs/antora/modules/tutorial/pages/first-application/index.adoc

+50-23
Original file line numberDiff line numberDiff line change
@@ -100,34 +100,61 @@ Open your favorite text editor and add the following:
100100
101101
<!-- Additional lines to be added here... -->
102102
103-
ifeval::["{artifact-release-type}" != "release"]
104-
<!-- (you only need this if you are using a milestone or snapshot version) -->
105-
<repositories>
106-
<repository>
107-
<id>spring-snapshots</id>
108-
<url>https://repo.spring.io/snapshot</url>
109-
<snapshots><enabled>true</enabled></snapshots>
110-
</repository>
111-
<repository>
112-
<id>spring-milestones</id>
113-
<url>https://repo.spring.io/milestone</url>
114-
</repository>
115-
</repositories>
116-
<pluginRepositories>
117-
<pluginRepository>
118-
<id>spring-snapshots</id>
119-
<url>https://repo.spring.io/snapshot</url>
120-
</pluginRepository>
121-
<pluginRepository>
122-
<id>spring-milestones</id>
123-
<url>https://repo.spring.io/milestone</url>
124-
</pluginRepository>
125-
</pluginRepositories>
103+
ifeval::["{build-and-artifact-release-type}" == "opensource-milestone"]
104+
<!-- (you don't need this if you are using a release version) -->
105+
<repositories>
106+
<repository>
107+
<id>spring-milestones</id>
108+
<url>https://repo.spring.io/milestone</url>
109+
</repository>
110+
</repositories>
111+
<pluginRepositories>
112+
<pluginRepository>
113+
<id>spring-milestones</id>
114+
<url>https://repo.spring.io/milestone</url>
115+
</pluginRepository>
116+
</pluginRepositories>
117+
endif::[]
118+
ifeval::["{build-and-artifact-release-type}" == "opensource-snapshot"]
119+
<!-- (you don't need this if you are using a release version) -->
120+
<repositories>
121+
<repository>
122+
<id>spring-snapshots</id>
123+
<url>https://repo.spring.io/snapshot</url>
124+
<snapshots><enabled>true</enabled></snapshots>
125+
</repository>
126+
<repository>
127+
<id>spring-milestones</id>
128+
<url>https://repo.spring.io/milestone</url>
129+
</repository>
130+
</repositories>
131+
<pluginRepositories>
132+
<pluginRepository>
133+
<id>spring-snapshots</id>
134+
<url>https://repo.spring.io/snapshot</url>
135+
</pluginRepository>
136+
<pluginRepository>
137+
<id>spring-milestones</id>
138+
<url>https://repo.spring.io/milestone</url>
139+
</pluginRepository>
140+
</pluginRepositories>
126141
endif::[]
127142
</project>
128143
----
129144

145+
ifeval::["{build-type}" == "opensource"]
130146
The preceding listing should give you a working build.
147+
endif::[]
148+
149+
ifeval::["{build-type}" == "commercial"]
150+
You will also have to configure your build to access the Spring Commercial repository.
151+
This is usual done through a local artifact repository that mirrors the content of the Spring Commercial repository.
152+
Alternatively, while it is not recommended, the Spring Commercial repository can also be accessed directly.
153+
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.
154+
155+
With the addition of the necessary repository configuration, the preceding listing should give you a working build.
156+
endif::[]
157+
131158
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).
132159

133160
NOTE: At this point, you could import the project into an IDE (most modern Java IDEs include built-in support for Maven).
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+
}

0 commit comments

Comments
 (0)