diff --git a/buildSrc/src/main/java/org/springframework/boot/build/AsciidoctorConventions.java b/buildSrc/src/main/java/org/springframework/boot/build/AsciidoctorConventions.java index 62634633f4..fa132cb1bb 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/AsciidoctorConventions.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/AsciidoctorConventions.java @@ -30,7 +30,7 @@ import org.gradle.api.Project; import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.Sync; -import org.springframework.boot.build.artifactory.ArtifactoryRepository; +import org.springframework.boot.build.artifacts.ArtifactRelease; import org.springframework.util.StringUtils; /** @@ -59,6 +59,7 @@ import org.springframework.util.StringUtils; * * * @author Andy Wilkinson + * @author Scott Frederick */ class AsciidoctorConventions { @@ -110,10 +111,12 @@ class AsciidoctorConventions { } private void configureCommonAttributes(Project project, AbstractAsciidoctorTask asciidoctorTask) { + ArtifactRelease artifacts = ArtifactRelease.forProject(project); Map attributes = new HashMap<>(); attributes.put("attribute-missing", "warn"); attributes.put("github-tag", determineGitHubTag(project)); - attributes.put("spring-boot-artifactory-repo", ArtifactoryRepository.forProject(project)); + attributes.put("artifact-release-type", artifacts.getType()); + attributes.put("artifact-download-repo", artifacts.getDownloadRepo()); attributes.put("revnumber", null); asciidoctorTask.attributes(attributes); } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/artifactory/ArtifactoryRepository.java b/buildSrc/src/main/java/org/springframework/boot/build/artifacts/ArtifactRelease.java similarity index 60% rename from buildSrc/src/main/java/org/springframework/boot/build/artifactory/ArtifactoryRepository.java rename to buildSrc/src/main/java/org/springframework/boot/build/artifacts/ArtifactRelease.java index 2ca1a3c18d..3cf861543b 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/artifactory/ArtifactoryRepository.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/artifacts/ArtifactRelease.java @@ -14,16 +14,17 @@ * limitations under the License. */ -package org.springframework.boot.build.artifactory; +package org.springframework.boot.build.artifacts; import org.gradle.api.Project; /** - * An Artifactory repository to which a build of Spring Boot can be published. + * Information about artifacts produced by a build. * * @author Andy Wilkinson + * @author Scott Frederick */ -public final class ArtifactoryRepository { +public final class ArtifactRelease { private static final String SNAPSHOT = "snapshot"; @@ -31,30 +32,33 @@ public final class ArtifactoryRepository { private static final String RELEASE = "release"; - private final String name; + private static final String SPRING_REPO = "https://repo.spring.io/%s"; - private ArtifactoryRepository(String name) { - this.name = name; + private static final String MAVEN_REPO = "https://repo.maven.apache.org/maven2"; + + private final String type; + + private ArtifactRelease(String type) { + this.type = type; } - public String getName() { - return this.name; + public String getType() { + return this.type; } - public boolean isRelease() { - return RELEASE.equals(this.name); + public String getDownloadRepo() { + return (this.isRelease()) ? MAVEN_REPO : String.format(SPRING_REPO, this.getType()); } - @Override - public String toString() { - return this.name; + public boolean isRelease() { + return RELEASE.equals(this.type); } - public static ArtifactoryRepository forProject(Project project) { - return new ArtifactoryRepository(determineArtifactoryRepo(project)); + public static ArtifactRelease forProject(Project project) { + return new ArtifactRelease(determineReleaseType(project)); } - private static String determineArtifactoryRepo(Project project) { + private static String determineReleaseType(Project project) { String version = project.getVersion().toString(); int modifierIndex = version.lastIndexOf('-'); if (modifierIndex == -1) { diff --git a/buildSrc/src/main/java/org/springframework/boot/build/cli/HomebrewFormula.java b/buildSrc/src/main/java/org/springframework/boot/build/cli/HomebrewFormula.java index 3197b0bc29..62e790a31c 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/cli/HomebrewFormula.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/cli/HomebrewFormula.java @@ -35,7 +35,7 @@ import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.TaskAction; import org.gradle.api.tasks.TaskExecutionException; -import org.springframework.boot.build.artifactory.ArtifactoryRepository; +import org.springframework.boot.build.artifacts.ArtifactRelease; /** * A {@link Task} for creating a Homebrew formula manifest. @@ -44,10 +44,6 @@ import org.springframework.boot.build.artifactory.ArtifactoryRepository; */ public class HomebrewFormula extends DefaultTask { - private static final String SPRING_REPO = "https://repo.spring.io/%s"; - - private static final String MAVEN_REPO = "https://repo.maven.apache.org/maven2"; - private Provider archive; private File template; @@ -99,7 +95,7 @@ public class HomebrewFormula extends DefaultTask { Map properties = new HashMap<>(additionalProperties); Project project = getProject(); properties.put("hash", sha256(this.archive.get().getAsFile())); - properties.put("repo", getRepo(project)); + properties.put("repo", ArtifactRelease.forProject(project).getDownloadRepo()); properties.put("project", project); return properties; } @@ -114,11 +110,6 @@ public class HomebrewFormula extends DefaultTask { } } - private String getRepo(Project project) { - ArtifactoryRepository artifactoryRepo = ArtifactoryRepository.forProject(project); - return (!artifactoryRepo.isRelease()) ? String.format(SPRING_REPO, artifactoryRepo.getName()) : MAVEN_REPO; - } - @TaskAction void createFormula() { createDescriptor(Collections.emptyMap()); diff --git a/buildSrc/src/test/java/org/springframework/boot/build/artifactory/ArtifactoryRepositoryTests.java b/buildSrc/src/test/java/org/springframework/boot/build/artifactory/ArtifactoryRepositoryTests.java deleted file mode 100644 index f878e1afdf..0000000000 --- a/buildSrc/src/test/java/org/springframework/boot/build/artifactory/ArtifactoryRepositoryTests.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2012-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.build.artifactory; - -import org.gradle.api.Project; -import org.gradle.testfixtures.ProjectBuilder; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Tests for {@link ArtifactoryRepository}. - * - * @author Andy Wilkinson - */ -class ArtifactoryRepositoryTests { - - @Test - void whenProjectVersionIsMilestoneThenRepositoryIsMilestone() { - Project project = ProjectBuilder.builder().build(); - project.setVersion("1.2.3-M1"); - assertThat(ArtifactoryRepository.forProject(project).getName()).isEqualTo("milestone"); - } - - @Test - void whenProjectVersionIsReleaseCandidateThenRepositoryIsMilestone() { - Project project = ProjectBuilder.builder().build(); - project.setVersion("1.2.3-RC1"); - assertThat(ArtifactoryRepository.forProject(project).getName()).isEqualTo("milestone"); - } - - @Test - void whenProjectVersionIsReleaseThenRepositoryIsRelease() { - Project project = ProjectBuilder.builder().build(); - project.setVersion("1.2.3"); - assertThat(ArtifactoryRepository.forProject(project).getName()).isEqualTo("release"); - } - - @Test - void whenProjectVersionIsSnapshotThenRepositoryIsSnapshot() { - Project project = ProjectBuilder.builder().build(); - project.setVersion("1.2.3-SNAPSHOT"); - assertThat(ArtifactoryRepository.forProject(project).getName()).isEqualTo("snapshot"); - } - -} diff --git a/buildSrc/src/test/java/org/springframework/boot/build/artifacts/ArtifactReleaseTests.java b/buildSrc/src/test/java/org/springframework/boot/build/artifacts/ArtifactReleaseTests.java new file mode 100644 index 0000000000..0a9d5e420a --- /dev/null +++ b/buildSrc/src/test/java/org/springframework/boot/build/artifacts/ArtifactReleaseTests.java @@ -0,0 +1,90 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.build.artifacts; + +import org.gradle.api.Project; +import org.gradle.testfixtures.ProjectBuilder; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link ArtifactRelease}. + * + * @author Andy Wilkinson + * @author Scott Frederick + */ +class ArtifactReleaseTests { + + @Test + void whenProjectVersionIsSnapshotThenTypeIsSnapshot() { + Project project = ProjectBuilder.builder().build(); + project.setVersion("1.2.3-SNAPSHOT"); + assertThat(ArtifactRelease.forProject(project).getType()).isEqualTo("snapshot"); + } + + @Test + void whenProjectVersionIsMilestoneThenTypeIsMilestone() { + Project project = ProjectBuilder.builder().build(); + project.setVersion("1.2.3-M1"); + assertThat(ArtifactRelease.forProject(project).getType()).isEqualTo("milestone"); + } + + @Test + void whenProjectVersionIsReleaseCandidateThenTypeIsMilestone() { + Project project = ProjectBuilder.builder().build(); + project.setVersion("1.2.3-RC1"); + assertThat(ArtifactRelease.forProject(project).getType()).isEqualTo("milestone"); + } + + @Test + void whenProjectVersionIsReleaseThenTypeIsRelease() { + Project project = ProjectBuilder.builder().build(); + project.setVersion("1.2.3"); + assertThat(ArtifactRelease.forProject(project).getType()).isEqualTo("release"); + } + + @Test + void whenProjectVersionIsSnapshotThenRepositoryIsArtifactorySnapshot() { + Project project = ProjectBuilder.builder().build(); + project.setVersion("1.2.3-SNAPSHOT"); + assertThat(ArtifactRelease.forProject(project).getDownloadRepo()).contains("repo.spring.io/snapshot"); + } + + @Test + void whenProjectVersionIsMilestoneThenRepositoryIsArtifactoryMilestone() { + Project project = ProjectBuilder.builder().build(); + project.setVersion("1.2.3-M1"); + assertThat(ArtifactRelease.forProject(project).getDownloadRepo()).contains("repo.spring.io/milestone"); + } + + @Test + void whenProjectVersionIsReleaseCandidateThenRepositoryIsArtifactoryMilestone() { + Project project = ProjectBuilder.builder().build(); + project.setVersion("1.2.3-RC1"); + assertThat(ArtifactRelease.forProject(project).getDownloadRepo()).contains("repo.spring.io/milestone"); + } + + @Test + void whenProjectVersionIsReleaseThenRepositoryIsMavenCentral() { + Project project = ProjectBuilder.builder().build(); + project.setVersion("1.2.3"); + assertThat(ArtifactRelease.forProject(project).getDownloadRepo()) + .contains("https://repo.maven.apache.org/maven2"); + } + +} diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc index 50792ec016..4f46a96f39 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc @@ -11,7 +11,7 @@ :docinfo: shared,private :attribute-missing: warn :chomp: default headers packages -:spring-boot-artifactory-repo: snapshot +:artifact-release-type: snapshot :github-tag: main :spring-boot-version: current :github-repo: spring-projects/spring-boot diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/first-application.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/first-application.adoc index edbd00ba0a..6d6725bd32 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/first-application.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/first-application.adoc @@ -61,7 +61,7 @@ Open your favorite text editor and add the following: -ifeval::["{spring-boot-artifactory-repo}" != "release"] +ifeval::["{artifact-release-type}" != "release"] diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/installing.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/installing.adoc index 0ad32e14b6..4f4f835551 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/installing.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started/installing.adoc @@ -74,13 +74,16 @@ You do not need to use the CLI to work with Spring Boot, but it is a quick way t [[getting-started.installing.cli.manual-installation]] ==== Manual Installation -You can download the Spring CLI distribution from the Spring software repository: +ifeval::["{artifact-release-type}" == "snapshot"] +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]. +endif::[] +ifeval::["{artifact-release-type}" != "snapshot"] +You can download the Spring CLI distribution from one of the following locations: -* 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] -* 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] +* {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] +* {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] +endif::[] -Cutting edge -https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-cli/[snapshot distributions] are also available. Once downloaded, follow the {github-raw}/spring-boot-project/spring-boot-cli/src/main/content/INSTALL.txt[INSTALL.txt] instructions from the unpacked archive. In summary, there is a `spring` script (`spring.bat` for Windows) in a `bin/` directory in the `.zip` file. diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/getting-started.adoc b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/getting-started.adoc index 2c5d3dd5df..5828e3b8d9 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/getting-started.adoc +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/getting-started.adoc @@ -2,7 +2,7 @@ = Getting Started To get started with the plugin it needs to be applied to your project. -ifeval::["{spring-boot-artifactory-repo}" == "release"] +ifeval::["{artifact-release-type}" == "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 +16,7 @@ include::../gradle/getting-started/apply-plugin-release.gradle[] include::../gradle/getting-started/apply-plugin-release.gradle.kts[] ---- endif::[] -ifeval::["{spring-boot-artifactory-repo}" == "milestone"] +ifeval::["{artifact-release-type}" == "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 +47,7 @@ include::../gradle/getting-started/apply-plugin-release.gradle[] include::../gradle/getting-started/apply-plugin-release.gradle.kts[] ---- endif::[] -ifeval::["{spring-boot-artifactory-repo}" == "snapshot"] +ifeval::["{artifact-release-type}" == "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): diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/managing-dependencies.adoc b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/managing-dependencies.adoc index 68d42db000..0b6be6238f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/managing-dependencies.adoc +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/managing-dependencies.adoc @@ -58,7 +58,7 @@ 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::["{spring-boot-artifactory-repo}" == "release"] +ifeval::["{artifact-release-type}" == "release"] [source,groovy,indent=0,subs="verbatim,attributes",role="primary"] .Groovy ---- @@ -71,7 +71,7 @@ include::../gradle/managing-dependencies/depend-on-plugin-release.gradle[] include::../gradle/managing-dependencies/depend-on-plugin-release.gradle.kts[] ---- endif::[] -ifeval::["{spring-boot-artifactory-repo}" == "milestone"] +ifeval::["{artifact-release-type}" == "milestone"] [source,groovy,indent=0,subs="verbatim,attributes",role="primary"] .Groovy ---- @@ -83,7 +83,7 @@ include::../gradle/managing-dependencies/depend-on-plugin-milestone.gradle[] include::../gradle/managing-dependencies/depend-on-plugin-release.gradle.kts[] ---- endif::[] -ifeval::["{spring-boot-artifactory-repo}" == "snapshot"] +ifeval::["{artifact-release-type}" == "snapshot"] [source,groovy,indent=0,subs="verbatim,attributes",role="primary"] .Groovy ----