Skip to content

Commit f396c51

Browse files
committed
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
1 parent 9cdc883 commit f396c51

File tree

4 files changed

+83
-4
lines changed

4 files changed

+83
-4
lines changed

buildSrc/src/main/java/org/springframework/boot/build/bom/Library.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,14 @@ public Library(String name, String calendarName, LibraryVersion version, List<Gr
9393
this.prohibitedVersions = prohibitedVersions;
9494
this.considerSnapshots = considerSnapshots;
9595
this.versionAlignment = versionAlignment;
96-
this.linkRootName = linkRootName;
96+
this.linkRootName = (linkRootName != null) ? linkRootName : generateLinkRootName(name);
9797
this.links = Collections.unmodifiableMap(links);
9898
}
9999

100+
private static String generateLinkRootName(String name) {
101+
return name.replace("-", "").replace(" ", "-").toLowerCase();
102+
}
103+
100104
public String getName() {
101105
return this.name;
102106
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2012-2024 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.bom;
18+
19+
import java.util.Collections;
20+
import java.util.List;
21+
import java.util.Map;
22+
import java.util.function.Function;
23+
24+
import org.junit.jupiter.api.Test;
25+
26+
import org.springframework.boot.build.bom.Library.Group;
27+
import org.springframework.boot.build.bom.Library.LibraryVersion;
28+
import org.springframework.boot.build.bom.Library.ProhibitedVersion;
29+
import org.springframework.boot.build.bom.Library.VersionAlignment;
30+
import org.springframework.boot.build.bom.bomr.version.DependencyVersion;
31+
32+
import static org.assertj.core.api.Assertions.assertThat;
33+
34+
/**
35+
* Tests for {@link Library}.
36+
*
37+
* @author Phillip Webb
38+
*/
39+
class LibraryTests {
40+
41+
@Test
42+
void getLinkRootNameWhenNoneSpecified() {
43+
String name = "Spring Framework";
44+
String calendarName = null;
45+
LibraryVersion version = new LibraryVersion(DependencyVersion.parse("1.2.3"));
46+
List<Group> groups = Collections.emptyList();
47+
List<ProhibitedVersion> prohibitedVersion = Collections.emptyList();
48+
boolean considerSnapshots = false;
49+
VersionAlignment versionAlignment = null;
50+
String linkRootName = null;
51+
Map<String, Function<LibraryVersion, String>> links = Collections.emptyMap();
52+
Library library = new Library(name, calendarName, version, groups, prohibitedVersion, considerSnapshots,
53+
versionAlignment, linkRootName, links);
54+
assertThat(library.getLinkRootName()).isEqualTo("spring-framework");
55+
}
56+
57+
@Test
58+
void getLinkRootNameWhenSpecified() {
59+
String name = "Spring Data BOM";
60+
String calendarName = null;
61+
LibraryVersion version = new LibraryVersion(DependencyVersion.parse("1.2.3"));
62+
List<Group> groups = Collections.emptyList();
63+
List<ProhibitedVersion> prohibitedVersion = Collections.emptyList();
64+
boolean considerSnapshots = false;
65+
VersionAlignment versionAlignment = null;
66+
String linkRootName = "spring-data";
67+
Map<String, Function<LibraryVersion, String>> links = Collections.emptyMap();
68+
Library library = new Library(name, calendarName, version, groups, prohibitedVersion, considerSnapshots,
69+
versionAlignment, linkRootName, links);
70+
assertThat(library.getLinkRootName()).isEqualTo("spring-data");
71+
}
72+
73+
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ mavenVersion=3.9.4
1414
nativeBuildToolsVersion=0.10.1
1515
springFrameworkVersion=6.1.5
1616
tomcatVersion=10.1.19
17+
snakeYamlVersion=2.2
1718

1819
kotlin.stdlib.default.dependency=false

spring-boot-project/spring-boot-dependencies/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ bom {
898898
}
899899
links {
900900
site("https://www.jooq.org")
901-
docs("https://www.jooq.org/doc/{jooq-version}/manual-single-page")
901+
docs("https://www.jooq.org/doc/{version}/manual-single-page")
902902
releaseNotes("https://github.com/jOOQ/jOOQ/releases/tag/version-{version}")
903903
}
904904
}
@@ -1778,7 +1778,7 @@ bom {
17781778
]
17791779
}
17801780
}
1781-
library("SnakeYAML", "2.2") {
1781+
library("SnakeYAML", "${snakeYamlVersion}") {
17821782
group("org.yaml") {
17831783
modules = [
17841784
"snakeyaml"
@@ -2029,7 +2029,7 @@ bom {
20292029
"spring-ws-bom"
20302030
]
20312031
}
2032-
links {
2032+
links("spring-webservices") {
20332033
site("https://spring.io/projects/spring-ws")
20342034
github("https://github.com/spring-projects/spring-ws")
20352035
javadoc("https://docs.spring.io/spring-ws/docs/{version}/api")
@@ -2110,6 +2110,7 @@ bom {
21102110
}
21112111
links {
21122112
site("https://tomcat.apache.org")
2113+
docs { version -> "https://tomcat.apache.org/tomcat-%s.%s-doc".formatted(version.major(), version.minor()) }
21132114
}
21142115
}
21152116
library("UnboundID LDAPSDK", "6.0.11") {

0 commit comments

Comments
 (0)