Skip to content

Commit 12537c7

Browse files
Merge branch '3.0.x'
Closes spring-projectsgh-34162
2 parents 6932a5c + cbac3c8 commit 12537c7

File tree

10 files changed

+133
-102
lines changed

10 files changed

+133
-102
lines changed

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.gradle.api.tasks.PathSensitivity;
3131
import org.gradle.api.tasks.Sync;
3232

33-
import org.springframework.boot.build.artifactory.ArtifactoryRepository;
33+
import org.springframework.boot.build.artifacts.ArtifactRelease;
3434
import org.springframework.util.StringUtils;
3535

3636
/**
@@ -59,6 +59,7 @@
5959
* </ul>
6060
*
6161
* @author Andy Wilkinson
62+
* @author Scott Frederick
6263
*/
6364
class AsciidoctorConventions {
6465

@@ -110,10 +111,12 @@ private void configureAsciidoctorTask(Project project, AbstractAsciidoctorTask a
110111
}
111112

112113
private void configureCommonAttributes(Project project, AbstractAsciidoctorTask asciidoctorTask) {
114+
ArtifactRelease artifacts = ArtifactRelease.forProject(project);
113115
Map<String, Object> attributes = new HashMap<>();
114116
attributes.put("attribute-missing", "warn");
115117
attributes.put("github-tag", determineGitHubTag(project));
116-
attributes.put("spring-boot-artifactory-repo", ArtifactoryRepository.forProject(project));
118+
attributes.put("artifact-release-type", artifacts.getType());
119+
attributes.put("artifact-download-repo", artifacts.getDownloadRepo());
117120
attributes.put("revnumber", null);
118121
asciidoctorTask.attributes(attributes);
119122
}

buildSrc/src/main/java/org/springframework/boot/build/artifactory/ArtifactoryRepository.java buildSrc/src/main/java/org/springframework/boot/build/artifacts/ArtifactRelease.java

+20-16
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,51 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.build.artifactory;
17+
package org.springframework.boot.build.artifacts;
1818

1919
import org.gradle.api.Project;
2020

2121
/**
22-
* An Artifactory repository to which a build of Spring Boot can be published.
22+
* Information about artifacts produced by a build.
2323
*
2424
* @author Andy Wilkinson
25+
* @author Scott Frederick
2526
*/
26-
public final class ArtifactoryRepository {
27+
public final class ArtifactRelease {
2728

2829
private static final String SNAPSHOT = "snapshot";
2930

3031
private static final String MILESTONE = "milestone";
3132

3233
private static final String RELEASE = "release";
3334

34-
private final String name;
35+
private static final String SPRING_REPO = "https://repo.spring.io/%s";
3536

36-
private ArtifactoryRepository(String name) {
37-
this.name = name;
37+
private static final String MAVEN_REPO = "https://repo.maven.apache.org/maven2";
38+
39+
private final String type;
40+
41+
private ArtifactRelease(String type) {
42+
this.type = type;
3843
}
3944

40-
public String getName() {
41-
return this.name;
45+
public String getType() {
46+
return this.type;
4247
}
4348

44-
public boolean isRelease() {
45-
return RELEASE.equals(this.name);
49+
public String getDownloadRepo() {
50+
return (this.isRelease()) ? MAVEN_REPO : String.format(SPRING_REPO, this.getType());
4651
}
4752

48-
@Override
49-
public String toString() {
50-
return this.name;
53+
public boolean isRelease() {
54+
return RELEASE.equals(this.type);
5155
}
5256

53-
public static ArtifactoryRepository forProject(Project project) {
54-
return new ArtifactoryRepository(determineArtifactoryRepo(project));
57+
public static ArtifactRelease forProject(Project project) {
58+
return new ArtifactRelease(determineReleaseType(project));
5559
}
5660

57-
private static String determineArtifactoryRepo(Project project) {
61+
private static String determineReleaseType(Project project) {
5862
String version = project.getVersion().toString();
5963
int modifierIndex = version.lastIndexOf('-');
6064
if (modifierIndex == -1) {

buildSrc/src/main/java/org/springframework/boot/build/cli/HomebrewFormula.java

+2-11
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import org.gradle.api.tasks.TaskAction;
3636
import org.gradle.api.tasks.TaskExecutionException;
3737

38-
import org.springframework.boot.build.artifactory.ArtifactoryRepository;
38+
import org.springframework.boot.build.artifacts.ArtifactRelease;
3939

4040
/**
4141
* A {@link Task} for creating a Homebrew formula manifest.
@@ -44,10 +44,6 @@
4444
*/
4545
public class HomebrewFormula extends DefaultTask {
4646

47-
private static final String SPRING_REPO = "https://repo.spring.io/%s";
48-
49-
private static final String MAVEN_REPO = "https://repo.maven.apache.org/maven2";
50-
5147
private Provider<RegularFile> archive;
5248

5349
private File template;
@@ -99,7 +95,7 @@ private Map<String, Object> getProperties(Map<String, Object> additionalProperti
9995
Map<String, Object> properties = new HashMap<>(additionalProperties);
10096
Project project = getProject();
10197
properties.put("hash", sha256(this.archive.get().getAsFile()));
102-
properties.put("repo", getRepo(project));
98+
properties.put("repo", ArtifactRelease.forProject(project).getDownloadRepo());
10399
properties.put("project", project);
104100
return properties;
105101
}
@@ -114,11 +110,6 @@ private String sha256(File file) {
114110
}
115111
}
116112

117-
private String getRepo(Project project) {
118-
ArtifactoryRepository artifactoryRepo = ArtifactoryRepository.forProject(project);
119-
return (!artifactoryRepo.isRelease()) ? String.format(SPRING_REPO, artifactoryRepo.getName()) : MAVEN_REPO;
120-
}
121-
122113
@TaskAction
123114
void createFormula() {
124115
createDescriptor(Collections.emptyMap());

buildSrc/src/test/java/org/springframework/boot/build/artifactory/ArtifactoryRepositoryTests.java

-60
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright 2012-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.build.artifacts;
18+
19+
import org.gradle.api.Project;
20+
import org.gradle.testfixtures.ProjectBuilder;
21+
import org.junit.jupiter.api.Test;
22+
23+
import static org.assertj.core.api.Assertions.assertThat;
24+
25+
/**
26+
* Tests for {@link ArtifactRelease}.
27+
*
28+
* @author Andy Wilkinson
29+
* @author Scott Frederick
30+
*/
31+
class ArtifactReleaseTests {
32+
33+
@Test
34+
void whenProjectVersionIsSnapshotThenTypeIsSnapshot() {
35+
Project project = ProjectBuilder.builder().build();
36+
project.setVersion("1.2.3-SNAPSHOT");
37+
assertThat(ArtifactRelease.forProject(project).getType()).isEqualTo("snapshot");
38+
}
39+
40+
@Test
41+
void whenProjectVersionIsMilestoneThenTypeIsMilestone() {
42+
Project project = ProjectBuilder.builder().build();
43+
project.setVersion("1.2.3-M1");
44+
assertThat(ArtifactRelease.forProject(project).getType()).isEqualTo("milestone");
45+
}
46+
47+
@Test
48+
void whenProjectVersionIsReleaseCandidateThenTypeIsMilestone() {
49+
Project project = ProjectBuilder.builder().build();
50+
project.setVersion("1.2.3-RC1");
51+
assertThat(ArtifactRelease.forProject(project).getType()).isEqualTo("milestone");
52+
}
53+
54+
@Test
55+
void whenProjectVersionIsReleaseThenTypeIsRelease() {
56+
Project project = ProjectBuilder.builder().build();
57+
project.setVersion("1.2.3");
58+
assertThat(ArtifactRelease.forProject(project).getType()).isEqualTo("release");
59+
}
60+
61+
@Test
62+
void whenProjectVersionIsSnapshotThenRepositoryIsArtifactorySnapshot() {
63+
Project project = ProjectBuilder.builder().build();
64+
project.setVersion("1.2.3-SNAPSHOT");
65+
assertThat(ArtifactRelease.forProject(project).getDownloadRepo()).contains("repo.spring.io/snapshot");
66+
}
67+
68+
@Test
69+
void whenProjectVersionIsMilestoneThenRepositoryIsArtifactoryMilestone() {
70+
Project project = ProjectBuilder.builder().build();
71+
project.setVersion("1.2.3-M1");
72+
assertThat(ArtifactRelease.forProject(project).getDownloadRepo()).contains("repo.spring.io/milestone");
73+
}
74+
75+
@Test
76+
void whenProjectVersionIsReleaseCandidateThenRepositoryIsArtifactoryMilestone() {
77+
Project project = ProjectBuilder.builder().build();
78+
project.setVersion("1.2.3-RC1");
79+
assertThat(ArtifactRelease.forProject(project).getDownloadRepo()).contains("repo.spring.io/milestone");
80+
}
81+
82+
@Test
83+
void whenProjectVersionIsReleaseThenRepositoryIsMavenCentral() {
84+
Project project = ProjectBuilder.builder().build();
85+
project.setVersion("1.2.3");
86+
assertThat(ArtifactRelease.forProject(project).getDownloadRepo())
87+
.contains("https://repo.maven.apache.org/maven2");
88+
}
89+
90+
}

spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
:docinfo: shared,private
1212
:attribute-missing: warn
1313
:chomp: default headers packages
14-
:spring-boot-artifactory-repo: snapshot
14+
:artifact-release-type: snapshot
1515
:github-tag: main
1616
:spring-boot-version: current
1717
:github-repo: spring-projects/spring-boot

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Open your favorite text editor and add the following:
6161
6262
<!-- Additional lines to be added here... -->
6363
64-
ifeval::["{spring-boot-artifactory-repo}" != "release"]
64+
ifeval::["{artifact-release-type}" != "release"]
6565
<!-- (you only need this if you are using a milestone or snapshot version) -->
6666
<repositories>
6767
<repository>

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,16 @@ You do not need to use the CLI to work with Spring Boot, but it is a quick way t
7373

7474
[[getting-started.installing.cli.manual-installation]]
7575
==== Manual Installation
76-
You can download the Spring CLI distribution from the Spring software repository:
76+
ifeval::["{artifact-release-type}" == "snapshot"]
77+
You can download one of the `spring-boot-cli-\*-bin.zip` or `spring-boot-cli-*-bin.tar.gz` files from the {artifact-download-repo}/org/springframework/boot/spring-boot-cli/{spring-boot-version}/[Spring software repository].
78+
endif::[]
79+
ifeval::["{artifact-release-type}" != "snapshot"]
80+
You can download the Spring CLI distribution from one of the following locations:
7781

78-
* https://repo.spring.io/{spring-boot-artifactory-repo}/org/springframework/boot/spring-boot-cli/{spring-boot-version}/spring-boot-cli-{spring-boot-version}-bin.zip[spring-boot-cli-{spring-boot-version}-bin.zip]
79-
* https://repo.spring.io/{spring-boot-artifactory-repo}/org/springframework/boot/spring-boot-cli/{spring-boot-version}/spring-boot-cli-{spring-boot-version}-bin.tar.gz[spring-boot-cli-{spring-boot-version}-bin.tar.gz]
82+
* {artifact-download-repo}/org/springframework/boot/spring-boot-cli/{spring-boot-version}/spring-boot-cli-{spring-boot-version}-bin.zip[spring-boot-cli-{spring-boot-version}-bin.zip]
83+
* {artifact-download-repo}/org/springframework/boot/spring-boot-cli/{spring-boot-version}/spring-boot-cli-{spring-boot-version}-bin.tar.gz[spring-boot-cli-{spring-boot-version}-bin.tar.gz]
84+
endif::[]
8085

81-
Cutting edge
82-
https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-cli/[snapshot distributions] are also available.
8386

8487
Once downloaded, follow the {github-raw}/spring-boot-project/spring-boot-tools/spring-boot-cli/src/main/content/INSTALL.txt[INSTALL.txt] instructions from the unpacked archive.
8588
In summary, there is a `spring` script (`spring.bat` for Windows) in a `bin/` directory in the `.zip` file.

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

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

5-
ifeval::["{spring-boot-artifactory-repo}" == "release"]
5+
ifeval::["{artifact-release-type}" == "release"]
66
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:
77
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
88
.Groovy
@@ -16,7 +16,7 @@ include::../gradle/getting-started/apply-plugin-release.gradle[]
1616
include::../gradle/getting-started/apply-plugin-release.gradle.kts[]
1717
----
1818
endif::[]
19-
ifeval::["{spring-boot-artifactory-repo}" == "milestone"]
19+
ifeval::["{artifact-release-type}" == "milestone"]
2020
The plugin is published to the Spring milestones repository.
2121
Gradle can be configured to use the milestones repository and the plugin can then be applied using the `plugins` block.
2222
To configure Gradle to use the milestones repository, add the following to your `settings.gradle` (Groovy) or `settings.gradle.kts` (Kotlin):
@@ -47,7 +47,7 @@ include::../gradle/getting-started/apply-plugin-release.gradle[]
4747
include::../gradle/getting-started/apply-plugin-release.gradle.kts[]
4848
----
4949
endif::[]
50-
ifeval::["{spring-boot-artifactory-repo}" == "snapshot"]
50+
ifeval::["{artifact-release-type}" == "snapshot"]
5151
The plugin is published to the Spring snapshots repository.
5252
Gradle can be configured to use the snapshots repository and the plugin can then be applied using the `plugins` block.
5353
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

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ 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::["{spring-boot-artifactory-repo}" == "release"]
61+
ifeval::["{artifact-release-type}" == "release"]
6262
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
6363
.Groovy
6464
----
@@ -71,7 +71,7 @@ include::../gradle/managing-dependencies/depend-on-plugin-release.gradle[]
7171
include::../gradle/managing-dependencies/depend-on-plugin-release.gradle.kts[]
7272
----
7373
endif::[]
74-
ifeval::["{spring-boot-artifactory-repo}" == "milestone"]
74+
ifeval::["{artifact-release-type}" == "milestone"]
7575
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
7676
.Groovy
7777
----
@@ -83,7 +83,7 @@ include::../gradle/managing-dependencies/depend-on-plugin-milestone.gradle[]
8383
include::../gradle/managing-dependencies/depend-on-plugin-release.gradle.kts[]
8484
----
8585
endif::[]
86-
ifeval::["{spring-boot-artifactory-repo}" == "snapshot"]
86+
ifeval::["{artifact-release-type}" == "snapshot"]
8787
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
8888
.Groovy
8989
----

0 commit comments

Comments
 (0)