From f396c5155038bc690e6a0fb57aaf5c2898245a57 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 19 Mar 2024 21:53:21 -0700 Subject: [PATCH] Further refine links in `spring-boot-dependencies` Fix a few links and allow the root name to be generated from the library name. See gh-39779 --- .../boot/build/bom/Library.java | 6 +- .../boot/build/bom/LibraryTests.java | 73 +++++++++++++++++++ gradle.properties | 1 + .../spring-boot-dependencies/build.gradle | 7 +- 4 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 buildSrc/src/test/java/org/springframework/boot/build/bom/LibraryTests.java diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/Library.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/Library.java index 781cf78be1d..8020c193cc9 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/Library.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/Library.java @@ -93,10 +93,14 @@ public class Library { this.prohibitedVersions = prohibitedVersions; this.considerSnapshots = considerSnapshots; this.versionAlignment = versionAlignment; - this.linkRootName = linkRootName; + this.linkRootName = (linkRootName != null) ? linkRootName : generateLinkRootName(name); this.links = Collections.unmodifiableMap(links); } + private static String generateLinkRootName(String name) { + return name.replace("-", "").replace(" ", "-").toLowerCase(); + } + public String getName() { return this.name; } diff --git a/buildSrc/src/test/java/org/springframework/boot/build/bom/LibraryTests.java b/buildSrc/src/test/java/org/springframework/boot/build/bom/LibraryTests.java new file mode 100644 index 00000000000..12b226b566d --- /dev/null +++ b/buildSrc/src/test/java/org/springframework/boot/build/bom/LibraryTests.java @@ -0,0 +1,73 @@ +/* + * Copyright 2012-2024 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.bom; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + +import org.junit.jupiter.api.Test; + +import org.springframework.boot.build.bom.Library.Group; +import org.springframework.boot.build.bom.Library.LibraryVersion; +import org.springframework.boot.build.bom.Library.ProhibitedVersion; +import org.springframework.boot.build.bom.Library.VersionAlignment; +import org.springframework.boot.build.bom.bomr.version.DependencyVersion; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link Library}. + * + * @author Phillip Webb + */ +class LibraryTests { + + @Test + void getLinkRootNameWhenNoneSpecified() { + String name = "Spring Framework"; + String calendarName = null; + LibraryVersion version = new LibraryVersion(DependencyVersion.parse("1.2.3")); + List groups = Collections.emptyList(); + List prohibitedVersion = Collections.emptyList(); + boolean considerSnapshots = false; + VersionAlignment versionAlignment = null; + String linkRootName = null; + Map> links = Collections.emptyMap(); + Library library = new Library(name, calendarName, version, groups, prohibitedVersion, considerSnapshots, + versionAlignment, linkRootName, links); + assertThat(library.getLinkRootName()).isEqualTo("spring-framework"); + } + + @Test + void getLinkRootNameWhenSpecified() { + String name = "Spring Data BOM"; + String calendarName = null; + LibraryVersion version = new LibraryVersion(DependencyVersion.parse("1.2.3")); + List groups = Collections.emptyList(); + List prohibitedVersion = Collections.emptyList(); + boolean considerSnapshots = false; + VersionAlignment versionAlignment = null; + String linkRootName = "spring-data"; + Map> links = Collections.emptyMap(); + Library library = new Library(name, calendarName, version, groups, prohibitedVersion, considerSnapshots, + versionAlignment, linkRootName, links); + assertThat(library.getLinkRootName()).isEqualTo("spring-data"); + } + +} diff --git a/gradle.properties b/gradle.properties index a5197483156..0f7c4b7053b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,5 +14,6 @@ mavenVersion=3.9.4 nativeBuildToolsVersion=0.10.1 springFrameworkVersion=6.1.5 tomcatVersion=10.1.19 +snakeYamlVersion=2.2 kotlin.stdlib.default.dependency=false diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 175b6a8c23a..e3f827fdf1d 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -898,7 +898,7 @@ bom { } links { site("https://www.jooq.org") - docs("https://www.jooq.org/doc/{jooq-version}/manual-single-page") + docs("https://www.jooq.org/doc/{version}/manual-single-page") releaseNotes("https://github.com/jOOQ/jOOQ/releases/tag/version-{version}") } } @@ -1778,7 +1778,7 @@ bom { ] } } - library("SnakeYAML", "2.2") { + library("SnakeYAML", "${snakeYamlVersion}") { group("org.yaml") { modules = [ "snakeyaml" @@ -2029,7 +2029,7 @@ bom { "spring-ws-bom" ] } - links { + links("spring-webservices") { site("https://spring.io/projects/spring-ws") github("https://github.com/spring-projects/spring-ws") javadoc("https://docs.spring.io/spring-ws/docs/{version}/api") @@ -2110,6 +2110,7 @@ bom { } links { site("https://tomcat.apache.org") + docs { version -> "https://tomcat.apache.org/tomcat-%s.%s-doc".formatted(version.major(), version.minor()) } } } library("UnboundID LDAPSDK", "6.0.11") {