Merge branch '4.1.x'

This commit is contained in:
Phillip Webb
2026-09-01 14:51:31 -07:00
16 changed files with 156 additions and 166 deletions
@@ -235,7 +235,7 @@ public class AntoraAsciidocAttributes {
library.getLinks().forEachLink((type, link) -> {
String linkRootName = (link.rootName() != null) ? link.rootName() : library.getLinkRootName();
String linkName = "url-" + linkRootName + "-" + type.attributeName();
attributes.put(linkName, link.url(library));
attributes.put(linkName, link.url(library.getVersion()));
link.packages()
.stream()
.map(this::packageAttributeName)
@@ -48,9 +48,9 @@ import org.springframework.boot.build.bom.Library.Exclusion;
import org.springframework.boot.build.bom.Library.FirstParty;
import org.springframework.boot.build.bom.Library.Group;
import org.springframework.boot.build.bom.Library.ImportedBom;
import org.springframework.boot.build.bom.Library.LibraryVersion;
import org.springframework.boot.build.bom.Library.Link;
import org.springframework.boot.build.bom.Library.LinkType;
import org.springframework.boot.build.bom.Library.LinkedVersion;
import org.springframework.boot.build.bom.Library.Links;
import org.springframework.boot.build.bom.Library.Module;
import org.springframework.boot.build.bom.Library.PermittedDependency;
@@ -123,7 +123,7 @@ public class BomExtension {
LibraryHandler libraryHandler = objects.newInstance(LibraryHandler.class, this.project,
(version != null) ? version : "");
action.execute(libraryHandler);
LibraryVersion libraryVersion = new LibraryVersion(DependencyVersion.parse(libraryHandler.version));
DependencyVersion libraryVersion = DependencyVersion.parse(libraryHandler.version);
FirstParty firstParty = null;
if (libraryHandler.firstParty) {
String releaseTrainId = (libraryHandler.releaseTrainId != null) ? libraryHandler.releaseTrainId
@@ -182,7 +182,7 @@ public class BomExtension {
this.libraries.add(library);
String versionProperty = library.getVersionProperty();
if (versionProperty != null) {
this.properties.put(versionProperty, library.getVersion().getVersion());
this.properties.put(versionProperty, library.getVersion());
}
for (Group group : library.getGroups()) {
for (Module module : group.getModules()) {
@@ -197,15 +197,14 @@ public class BomExtension {
private void addModule(Library library, DependencyHandler dependencies, String versionProperty, Group group,
Module module) {
putArtifactVersionProperty(group.getId(), module.getName(), module.getClassifier(), versionProperty);
String constraint = createDependencyNotation(group.getId(), module.getName(),
library.getVersion().getVersion());
String constraint = createDependencyNotation(group.getId(), module.getName(), library.getVersion());
dependencies.getConstraints().add(JavaPlatformPlugin.API_CONFIGURATION_NAME, constraint);
}
private void addBomImport(Library library, DependencyHandler dependencies, String versionProperty, Group group,
String bomImport) {
putArtifactVersionProperty(group.getId(), bomImport, versionProperty);
String bomDependency = createDependencyNotation(group.getId(), bomImport, library.getVersion().getVersion());
String bomDependency = createDependencyNotation(group.getId(), bomImport, library.getVersion());
dependencies.add(JavaPlatformPlugin.API_CONFIGURATION_NAME, dependencies.platform(bomDependency));
dependencies.add(BomPlugin.API_ENFORCED_CONFIGURATION_NAME, dependencies.enforcedPlatform(bomDependency));
}
@@ -532,7 +531,7 @@ public class BomExtension {
site(asFactory(linkTemplate));
}
public void site(Function<LibraryVersion, String> linkFactory) {
public void site(Function<LinkedVersion, String> linkFactory) {
add(LinkType.SITE, linkFactory);
}
@@ -540,7 +539,7 @@ public class BomExtension {
github(asFactory(linkTemplate));
}
public void github(Function<LibraryVersion, String> linkFactory) {
public void github(Function<LinkedVersion, String> linkFactory) {
add(LinkType.GITHUB, linkFactory);
}
@@ -548,7 +547,7 @@ public class BomExtension {
docs(asFactory(linkTemplate));
}
public void docs(Function<LibraryVersion, String> linkFactory) {
public void docs(Function<LinkedVersion, String> linkFactory) {
add(LinkType.DOCS, linkFactory);
}
@@ -560,15 +559,15 @@ public class BomExtension {
javadoc(asFactory(linkTemplate), packages);
}
public void javadoc(Function<LibraryVersion, String> linkFactory) {
public void javadoc(Function<LinkedVersion, String> linkFactory) {
add(LinkType.JAVADOC, linkFactory);
}
public void javadoc(Function<LibraryVersion, String> linkFactory, String... packages) {
public void javadoc(Function<LinkedVersion, String> linkFactory, String... packages) {
add(LinkType.JAVADOC, linkFactory, packages);
}
public void javadoc(String rootName, Function<LibraryVersion, String> linkFactory, String... packages) {
public void javadoc(String rootName, Function<LinkedVersion, String> linkFactory, String... packages) {
add(rootName, LinkType.JAVADOC, linkFactory, packages);
}
@@ -576,7 +575,7 @@ public class BomExtension {
releaseNotes(asFactory(linkTemplate));
}
public void releaseNotes(Function<LibraryVersion, String> linkFactory) {
public void releaseNotes(Function<LinkedVersion, String> linkFactory) {
add(LinkType.RELEASE_NOTES, linkFactory);
}
@@ -584,25 +583,25 @@ public class BomExtension {
layersXsd(asFactory(linkTemplate));
}
public void layersXsd(Function<LibraryVersion, String> linkFactory) {
public void layersXsd(Function<LinkedVersion, String> linkFactory) {
add(LinkType.LAYERS_XSD, linkFactory);
}
private void add(LinkType name, Function<LibraryVersion, String> linkFactory) {
private void add(LinkType name, Function<LinkedVersion, String> linkFactory) {
add(name, linkFactory, null);
}
private void add(LinkType type, Function<LibraryVersion, String> linkFactory, String[] packages) {
private void add(LinkType type, Function<LinkedVersion, String> linkFactory, String[] packages) {
add(null, type, linkFactory, packages);
}
private void add(String rootName, LinkType type, Function<LibraryVersion, String> linkFactory,
private void add(String rootName, LinkType type, Function<LinkedVersion, String> linkFactory,
String[] packages) {
Link link = new Link(rootName, linkFactory, (packages != null) ? List.of(packages) : null);
this.links.computeIfAbsent(type, (key) -> new ArrayList<>()).add(link);
}
private Function<LibraryVersion, String> asFactory(String linkTemplate) {
private Function<LinkedVersion, String> asFactory(String linkTemplate) {
return (version) -> {
PlaceholderResolver resolver = (name) -> "version".equals(name) ? version.toString() : null;
return new PropertyPlaceholderHelper("{", "}").replacePlaceholders(linkTemplate, resolver);
@@ -254,7 +254,7 @@ public class BomPlugin implements Plugin<Project> {
plugin.appendNode("artifactId", pluginName);
String versionProperty = library.getVersionProperty();
String value = (versionProperty != null) ? "${" + versionProperty + "}"
: library.getVersion().getVersion().toString();
: library.getVersion().toString();
plugin.appendNode("version", value);
}
}
@@ -77,21 +77,20 @@ class BomResolver {
List<Bom> imports = new ArrayList<>();
for (Group group : library.getGroups()) {
for (Module module : group.getModules()) {
Id id = new Id(group.getId(), module.getName(), library.getVersion().getVersion().toString());
Id id = new Id(group.getId(), module.getName(), library.getVersion().toString());
managedDependencies.add(id);
}
for (ImportedBom imported : group.getBoms()) {
Bom bom = bomFrom(resolveBom(
"%s:%s:%s".formatted(group.getId(), imported.name(), library.getVersion().getVersion())));
Bom bom = bomFrom(
resolveBom("%s:%s:%s".formatted(group.getId(), imported.name(), library.getVersion())));
imports.add(bom);
}
}
List<JavadocLink> javadocLinks = javadocLinksOf(library).stream()
.map((link) -> new JavadocLink(URI.create(link.url(library)), link.packages()))
.map((link) -> new JavadocLink(URI.create(link.url(library.getVersion())), link.packages()))
.toList();
ResolvedLibrary resolvedLibrary = new ResolvedLibrary(library.getName(),
library.getVersion().getVersion().toString(), library.getVersionProperty(), managedDependencies,
imports, new Links(javadocLinks));
ResolvedLibrary resolvedLibrary = new ResolvedLibrary(library.getName(), library.getVersion().toString(),
library.getVersionProperty(), managedDependencies, imports, new Links(javadocLinks));
libraries.add(resolvedLibrary);
}
String[] idComponents = bomExtension.getId().split(":");
@@ -136,7 +136,7 @@ public abstract class CheckBom extends DefaultTask {
for (Group group : library.getGroups()) {
for (Module module : group.getModules()) {
if (!module.getExclusions().isEmpty()) {
checkExclusions(group.getId(), module, library.getVersion().getVersion(), errors);
checkExclusions(group.getId(), module, library.getVersion(), errors);
}
}
}
@@ -183,9 +183,9 @@ public abstract class CheckBom extends DefaultTask {
@Override
public List<String> check(Library library) {
List<String> errors = new ArrayList<>();
ArtifactVersion currentVersion = new DefaultArtifactVersion(library.getVersion().getVersion().toString());
ArtifactVersion currentVersion = new DefaultArtifactVersion(library.getVersion().toString());
for (ProhibitedVersion prohibited : library.getProhibitedVersions()) {
if (prohibited.isProhibited(library.getVersion().getVersion().toString())) {
if (prohibited.isProhibited(library.getVersion().toString())) {
errors.add("Current version " + currentVersion + " is prohibited");
}
else {
@@ -232,9 +232,9 @@ public abstract class CheckBom extends DefaultTask {
Set<String> alignedVersions = versionAlignment.resolve();
if (alignedVersions.size() == 1) {
String alignedVersion = alignedVersions.iterator().next();
if (!alignedVersion.equals(library.getVersion().getVersion().toString())) {
errors.add("Version " + library.getVersion().getVersion() + " is misaligned. It should be "
+ alignedVersion + ".");
if (!alignedVersion.equals(library.getVersion().toString())) {
errors.add(
"Version " + library.getVersion() + " is misaligned. It should be " + alignedVersion + ".");
}
}
else {
@@ -296,7 +296,7 @@ public abstract class CheckBom extends DefaultTask {
BomAlignment alignsWithBom = library.getAlignsWithBom();
if (alignsWithBom != null) {
Bom mavenBom = this.bomResolver
.resolveMavenBom(alignsWithBom.getCoordinates() + ":" + library.getVersion().getVersion());
.resolveMavenBom(alignsWithBom.getCoordinates() + ":" + library.getVersion());
checkDependencyManagementAlignment(resolvedLibrary, mavenBom, errors, alignsWithBom::exclude);
}
return errors;
@@ -64,7 +64,7 @@ public abstract class CheckLinks extends DefaultTask {
library.getLinks().forEachLink((type, link) -> {
URI uri;
try {
uri = new URI(link.url(library));
uri = new URI(link.url(library.getVersion()));
ResponseEntity<String> response = restClient.head().uri(uri).retrieve().toEntity(String.class);
System.out.printf("[%3d] %s - %s (%s)%n", response.getStatusCode().value(), library.getName(), type,
uri);
@@ -51,6 +51,7 @@ import org.w3c.dom.Document;
import org.springframework.boot.build.bom.ResolvedBom.Id;
import org.springframework.boot.build.bom.bomr.version.DependencyVersion;
import org.springframework.boot.build.xml.XmlDocument;
import org.springframework.util.Assert;
/**
* A collection of modules, Maven plugins, and Maven boms that are versioned and released
@@ -64,7 +65,7 @@ public class Library {
private final String calendarName;
private final LibraryVersion version;
private final DependencyVersion version;
private final List<Group> groups;
@@ -102,7 +103,7 @@ public class Library {
* {@code null} to generate one based on the library {@code name}
* @param links a list of HTTP links relevant to the library
*/
public Library(String name, String calendarName, LibraryVersion version, List<Group> groups,
public Library(String name, String calendarName, DependencyVersion version, List<Group> groups,
UpgradePolicy upgradePolicy, List<ProhibitedVersion> prohibitedVersions, FirstParty firstParty,
VersionAlignment versionAlignment, BomAlignment bomAlignment, String linkRootName, Links links) {
this.name = name;
@@ -132,7 +133,7 @@ public class Library {
return this.calendarName;
}
public LibraryVersion getVersion() {
public DependencyVersion getVersion() {
return this.version;
}
@@ -184,7 +185,7 @@ public class Library {
if (links.size() > 1) {
throw new IllegalStateException("Expected a single '%s' link for %s".formatted(type, getName()));
}
return links.get(0).url(this);
return links.get(0).url(getVersion());
}
public List<Link> getLinks(LinkType type) {
@@ -195,7 +196,7 @@ public class Library {
return getName() + " " + getVersion();
}
public Library withVersion(LibraryVersion version) {
public Library withVersion(DependencyVersion version) {
return new Library(this.name, this.calendarName, version, this.groups, this.upgradePolicy,
this.prohibitedVersions, this.firstParty, this.versionAlignment, this.bomAlignment, this.linkRootName,
this.links);
@@ -257,67 +258,6 @@ public class Library {
}
public static class LibraryVersion {
private final DependencyVersion version;
public LibraryVersion(DependencyVersion version) {
this.version = version;
}
public DependencyVersion getVersion() {
return this.version;
}
public int[] componentInts() {
return Arrays.stream(parts()).mapToInt(Integer::parseInt).toArray();
}
public String major() {
return parts()[0];
}
public String minor() {
return parts()[1];
}
public String patch() {
return parts()[2];
}
@Override
public String toString() {
return this.version.toString();
}
public String toString(String separator) {
return this.version.toString().replace(".", separator);
}
public String forAntora() {
String[] parts = parts();
String result = parts[0] + "." + parts[1];
if (toString().endsWith("SNAPSHOT")) {
result += "-SNAPSHOT";
}
return result;
}
public String forMajorMinorGeneration() {
String[] parts = parts();
String result = parts[0] + "." + parts[1] + ".x";
if (toString().endsWith("SNAPSHOT")) {
result += "-SNAPSHOT";
}
return result;
}
private String[] parts() {
return toString().split("[.-]");
}
}
/**
* A collection of modules, Maven plugins, and Maven boms with the same group ID.
*/
@@ -539,8 +479,7 @@ public class Library {
private List<Dependency> getAligningDependencies() {
if (this.managedBy == null) {
Library fromLibrary = findFromLibrary();
return List
.of(this.project.getDependencies().create(this.from + ":" + fromLibrary.getVersion().getVersion()));
return List.of(this.project.getDependencies().create(this.from + ":" + fromLibrary.getVersion()));
}
else {
Library managingLibrary = findManagingLibrary();
@@ -579,13 +518,10 @@ public class Library {
if (manager == null) {
return Collections.emptyList();
}
return manager.getGroups()
.stream()
.flatMap((group) -> group.getBoms()
.stream()
.map((bom) -> this.project.getDependencies()
.platform(group.getId() + ":" + bom.name() + ":" + manager.getVersion().getVersion())))
.toList();
return manager.getGroups().stream().flatMap((group) -> group.getBoms().stream().map((bom) -> {
String plaform = group.getId() + ":" + bom.name() + ":" + manager.getVersion();
return this.project.getDependencies().platform(plaform);
})).toList();
}
String getFrom() {
@@ -671,13 +607,10 @@ public class Library {
if (manager == null) {
return Collections.emptyList();
}
return manager.getGroups()
.stream()
.flatMap((group) -> group.getBoms()
.stream()
.map((bom) -> this.project.getDependencies()
.platform(group.getId() + ":" + bom.name() + ":" + manager.getVersion().getVersion())))
.toList();
return manager.getGroups().stream().flatMap((group) -> group.getBoms().stream().map((bom) -> {
String platform = group.getId() + ":" + bom.name() + ":" + manager.getVersion();
return this.project.getDependencies().platform(platform);
})).toList();
}
private String propertyFrom(File pomFile) {
@@ -778,7 +711,7 @@ public class Library {
}
public record Link(String rootName, Function<LibraryVersion, String> factory, List<String> packages) {
public record Link(String rootName, Function<LinkedVersion, String> factory, List<String> packages) {
private static final Pattern PACKAGE_EXPAND = Pattern.compile("^(.*)\\[(.*)\\]$");
@@ -800,12 +733,72 @@ public class Library {
return Stream.of(suffixes).map((suffix) -> root + suffix);
}
public String url(Library library) {
return url(library.getVersion());
public String url(DependencyVersion version) {
return url(new LinkedVersion(version));
}
public String url(LibraryVersion libraryVersion) {
return factory().apply(libraryVersion);
public String url(LinkedVersion version) {
return factory().apply(version);
}
}
/**
* A version used when resolving a {@link Link}.
*
* @param version the underlying version
*/
public record LinkedVersion(Object version) {
public LinkedVersion {
Assert.notNull(version, "'version' must not be null");
}
public int[] componentInts() {
return Arrays.stream(parts()).mapToInt(Integer::parseInt).toArray();
}
public String major() {
return parts()[0];
}
public String minor() {
return parts()[1];
}
public String patch() {
return parts()[2];
}
@Override
public String toString() {
return version().toString();
}
public String toString(String separator) {
return version().toString().replace(".", separator);
}
public String forAntora() {
String[] parts = parts();
String result = parts[0] + "." + parts[1];
if (toString().endsWith("SNAPSHOT")) {
result += "-SNAPSHOT";
}
return result;
}
public String forMajorMinorGeneration() {
String[] parts = parts();
String result = parts[0] + "." + parts[1] + ".x";
if (toString().endsWith("SNAPSHOT")) {
result += "-SNAPSHOT";
}
return result;
}
private String[] parts() {
return toString().split("[.-]");
}
}
@@ -82,11 +82,11 @@ public final class InteractiveUpgradeResolver implements UpgradeResolver {
Set<String> alignedVersions = (alignment != null) ? alignment.resolve() : null;
if (alignedVersions != null && alignedVersions.size() == 1) {
DependencyVersion alignedVersion = DependencyVersion.parse(alignedVersions.iterator().next());
if (alignedVersion.equals(library.getVersion().getVersion())) {
if (alignedVersion.equals(library.getVersion())) {
return new VersionOption.AlignedVersionOption(alignedVersion, alignment);
}
}
return new VersionOption(library.getVersion().getVersion());
return new VersionOption(library.getVersion());
}
private VersionOption selectOption(VersionOption defaultOption, Library library,
@@ -97,7 +97,7 @@ class StandardLibraryUpdateResolver implements LibraryUpdateResolver {
Set<String> alignedVersions = versionAlignment.resolve();
if (alignedVersions != null && alignedVersions.size() == 1) {
DependencyVersion alignedVersion = DependencyVersion.parse(alignedVersions.iterator().next());
if (!alignedVersion.equals(library.getVersion().getVersion())) {
if (!alignedVersion.equals(library.getVersion())) {
return new VersionOption.AlignedVersionOption(alignedVersion, versionAlignment);
}
}
@@ -305,11 +305,11 @@ public abstract class UpgradeDependencies extends DefaultTask {
UpgradePolicy libraryPolicy = library.getUpgradePolicy();
UpgradePolicy bomPolicy = this.bom.getUpgrade().getPolicy();
UpgradePolicy upgradePolicy = UpgradePolicy.max(libraryPolicy, bomPolicy);
return upgradePolicy.test(candidate, library.getVersion().getVersion());
return upgradePolicy.test(candidate, library.getVersion());
}
private boolean isAnUpgrade(Library library, DependencyVersion candidate) {
return library.getVersion().getVersion().isUpgrade(candidate, this.movingToSnapshots);
return library.getVersion().isUpgrade(candidate, this.movingToSnapshots);
}
private boolean isNotProhibited(Library library, DependencyVersion candidate) {
@@ -19,7 +19,6 @@ package org.springframework.boot.build.bom.bomr;
import java.util.List;
import org.springframework.boot.build.bom.Library;
import org.springframework.boot.build.bom.Library.LibraryVersion;
import org.springframework.boot.build.bom.Library.VersionAlignment;
import org.springframework.boot.build.bom.bomr.version.DependencyVersion;
import org.springframework.util.StringUtils;
@@ -47,7 +46,7 @@ class VersionOption {
}
Upgrade upgrade(Library library) {
return new Upgrade(library, library.withVersion(new LibraryVersion(this.version)));
return new Upgrade(library, library.withVersion(this.version));
}
static final class AlignedVersionOption extends VersionOption {
@@ -102,8 +101,7 @@ class VersionOption {
@Override
Upgrade upgrade(Library library) {
return new Upgrade(library, library.withVersion(new LibraryVersion(super.version)),
library.withVersion(new LibraryVersion(this.releaseVersion)));
return new Upgrade(library, library.withVersion(super.version), library.withVersion(this.releaseVersion));
}
}
@@ -29,9 +29,9 @@ import org.springframework.boot.build.bom.Library;
import org.springframework.boot.build.bom.Library.BomAlignment;
import org.springframework.boot.build.bom.Library.FirstParty;
import org.springframework.boot.build.bom.Library.Group;
import org.springframework.boot.build.bom.Library.LibraryVersion;
import org.springframework.boot.build.bom.Library.Link;
import org.springframework.boot.build.bom.Library.LinkType;
import org.springframework.boot.build.bom.Library.LinkedVersion;
import org.springframework.boot.build.bom.Library.Links;
import org.springframework.boot.build.bom.Library.ProhibitedVersion;
import org.springframework.boot.build.bom.Library.VersionAlignment;
@@ -214,7 +214,7 @@ class AntoraAsciidocAttributesTests {
.containsEntry("javadoc-location-org-springframework-util", "{url-spring-framework-javadoc}");
}
private List<Link> singleLink(Function<LibraryVersion, String> factory, String... packages) {
private List<Link> singleLink(Function<LinkedVersion, String> factory, String... packages) {
Link link = new Link(null, factory, List.of(packages));
return List.of(link);
}
@@ -234,7 +234,7 @@ class AntoraAsciidocAttributesTests {
private Library mockLibrary(Map<LinkType, List<Link>> links) {
String name = "Spring Framework";
String calendarName = null;
LibraryVersion version = new LibraryVersion(DependencyVersion.parse("1.2.3"));
DependencyVersion version = DependencyVersion.parse("1.2.3");
List<Group> groups = Collections.emptyList();
List<ProhibitedVersion> prohibitedVersion = Collections.emptyList();
FirstParty firstParty = null;
@@ -19,12 +19,13 @@ package org.springframework.boot.build.bom;
import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.boot.build.bom.Library.BomAlignment;
import org.springframework.boot.build.bom.Library.FirstParty;
import org.springframework.boot.build.bom.Library.Group;
import org.springframework.boot.build.bom.Library.LibraryVersion;
import org.springframework.boot.build.bom.Library.LinkedVersion;
import org.springframework.boot.build.bom.Library.Links;
import org.springframework.boot.build.bom.Library.ProhibitedVersion;
import org.springframework.boot.build.bom.Library.VersionAlignment;
@@ -43,7 +44,7 @@ class LibraryTests {
void getLinkRootNameWhenNoneSpecified() {
String name = "Spring Framework";
String calendarName = null;
LibraryVersion version = new LibraryVersion(DependencyVersion.parse("1.2.3"));
DependencyVersion version = DependencyVersion.parse("1.2.3");
List<Group> groups = Collections.emptyList();
List<ProhibitedVersion> prohibitedVersion = Collections.emptyList();
FirstParty firstParty = null;
@@ -60,7 +61,7 @@ class LibraryTests {
void getLinkRootNameWhenSpecified() {
String name = "Spring Data BOM";
String calendarName = null;
LibraryVersion version = new LibraryVersion(DependencyVersion.parse("1.2.3"));
DependencyVersion version = DependencyVersion.parse("1.2.3");
List<Group> groups = Collections.emptyList();
List<ProhibitedVersion> prohibitedVersion = Collections.emptyList();
FirstParty firstParty = null;
@@ -73,16 +74,21 @@ class LibraryTests {
assertThat(library.getLinkRootName()).isEqualTo("spring-data");
}
@Test
void toMajorMinorGenerationWithRelease() {
LibraryVersion version = new LibraryVersion(DependencyVersion.parse("1.2.3"));
assertThat(version.forMajorMinorGeneration()).isEqualTo("1.2.x");
}
@Nested
class LinkedVersionTests {
@Test
void toMajorMinorGenerationWithRelease() {
LinkedVersion version = new LinkedVersion(DependencyVersion.parse("1.2.3"));
assertThat(version.forMajorMinorGeneration()).isEqualTo("1.2.x");
}
@Test
void toMajorMinorGenerationWithSnapshot() {
LinkedVersion version = new LinkedVersion(DependencyVersion.parse("2.0.0-SNAPSHOT"));
assertThat(version.forMajorMinorGeneration()).isEqualTo("2.0.x-SNAPSHOT");
}
@Test
void toMajorMinorGenerationWithSnapshot() {
LibraryVersion version = new LibraryVersion(DependencyVersion.parse("2.0.0-SNAPSHOT"));
assertThat(version.forMajorMinorGeneration()).isEqualTo("2.0.x-SNAPSHOT");
}
}
@@ -24,7 +24,6 @@ import org.gradle.api.provider.Provider;
import org.junit.jupiter.api.Test;
import org.springframework.boot.build.bom.Library;
import org.springframework.boot.build.bom.Library.LibraryVersion;
import org.springframework.boot.build.bom.bomr.version.DependencyVersion;
import static org.assertj.core.api.Assertions.assertThat;
@@ -47,8 +46,7 @@ class InteractiveUpgradeResolverTests {
libaryUpdateResolver);
List<Library> libraries = new ArrayList<>();
DependencyVersion version = DependencyVersion.parse("1.0.0");
LibraryVersion libraryVersion = new LibraryVersion(version);
Library library = new Library("test", null, libraryVersion, null, null, null, null, null, null, null, null);
Library library = new Library("test", null, version, null, null, null, null, null, null, null, null);
libraries.add(library);
List<Library> librariesToUpgrade = new ArrayList<>();
librariesToUpgrade.add(library);
@@ -60,7 +58,7 @@ class InteractiveUpgradeResolverTests {
Provider<Object> providerOfVersionOption = providerOf(versionOption);
given(userInputHandler.askUser(any())).willReturn(providerOfVersionOption);
List<Upgrade> upgrades = upgradeResolver.resolveUpgrades(librariesToUpgrade, libraries);
assertThat(upgrades.get(0).to().getVersion().getVersion()).isEqualTo(updateVersion);
assertThat(upgrades.get(0).to().getVersion()).isEqualTo(updateVersion);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.boot.build.bom.Library;
import org.springframework.boot.build.bom.Library.LibraryVersion;
import org.springframework.boot.build.bom.bomr.version.DependencyVersion;
import org.springframework.util.FileCopyUtils;
@@ -51,10 +50,10 @@ class UpgradeApplicatorTests {
String originalContents = Files.readString(bom.toPath());
File gradleProperties = new File(this.temp, "gradle.properties");
FileCopyUtils.copy(new File("src/test/resources/gradle.properties"), gradleProperties);
Library activeMq = new Library("ActiveMQ", null, new LibraryVersion(DependencyVersion.parse("5.15.11")), null,
null, null, null, null, null, null, null);
Library activeMq = new Library("ActiveMQ", null, DependencyVersion.parse("5.15.11"), null, null, null, null,
null, null, null, null);
new UpgradeApplicator(bom.toPath(), gradleProperties.toPath())
.apply(new Upgrade(activeMq, activeMq.withVersion(new LibraryVersion(DependencyVersion.parse("5.16")))));
.apply(new Upgrade(activeMq, activeMq.withVersion(DependencyVersion.parse("5.16"))));
String bomContents = Files.readString(bom.toPath());
assertThat(bomContents).hasSize(originalContents.length() - 3);
}
@@ -65,10 +64,10 @@ class UpgradeApplicatorTests {
FileCopyUtils.copy(new File("src/test/resources/bom.gradle"), bom);
File gradleProperties = new File(this.temp, "gradle.properties");
FileCopyUtils.copy(new File("src/test/resources/gradle.properties"), gradleProperties);
Library kotlin = new Library("Kotlin", null, new LibraryVersion(DependencyVersion.parse("1.3.70")), null, null,
null, null, null, null, null, null);
Library kotlin = new Library("Kotlin", null, DependencyVersion.parse("1.3.70"), null, null, null, null, null,
null, null, null);
new UpgradeApplicator(bom.toPath(), gradleProperties.toPath())
.apply(new Upgrade(kotlin, kotlin.withVersion(new LibraryVersion(DependencyVersion.parse("1.4")))));
.apply(new Upgrade(kotlin, kotlin.withVersion(DependencyVersion.parse("1.4"))));
Properties properties = new Properties();
try (InputStream in = new FileInputStream(gradleProperties)) {
properties.load(in);
@@ -19,7 +19,6 @@ package org.springframework.boot.build.bom.bomr;
import org.junit.jupiter.api.Test;
import org.springframework.boot.build.bom.Library;
import org.springframework.boot.build.bom.Library.LibraryVersion;
import org.springframework.boot.build.bom.bomr.version.DependencyVersion;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,9 +32,9 @@ class UpgradeTests {
@Test
void createToRelease() {
Library from = new Library("Test", null, new LibraryVersion(DependencyVersion.parse("1.0.0")), null, null, null,
null, null, null, null, null);
Upgrade upgrade = new Upgrade(from, from.withVersion(new LibraryVersion(DependencyVersion.parse("1.0.1"))));
Library from = new Library("Test", null, DependencyVersion.parse("1.0.0"), null, null, null, null, null, null,
null, null);
Upgrade upgrade = new Upgrade(from, from.withVersion(DependencyVersion.parse("1.0.1")));
assertThat(upgrade.from().getNameAndVersion()).isEqualTo("Test 1.0.0");
assertThat(upgrade.to().getNameAndVersion()).isEqualTo("Test 1.0.1");
assertThat(upgrade.toRelease().getNameAndVersion()).isEqualTo("Test 1.0.1");
@@ -43,11 +42,10 @@ class UpgradeTests {
@Test
void createToSnapshot() {
Library from = new Library("Test", null, new LibraryVersion(DependencyVersion.parse("1.0.0")), null, null, null,
null, null, null, null, null);
Upgrade upgrade = new Upgrade(from,
from.withVersion(new LibraryVersion(DependencyVersion.parse("1.0.1-SNAPSHOT"))),
from.withVersion(new LibraryVersion(DependencyVersion.parse("1.0.1"))));
Library from = new Library("Test", null, DependencyVersion.parse("1.0.0"), null, null, null, null, null, null,
null, null);
Upgrade upgrade = new Upgrade(from, from.withVersion(DependencyVersion.parse("1.0.1-SNAPSHOT")),
from.withVersion(DependencyVersion.parse("1.0.1")));
assertThat(upgrade.from().getNameAndVersion()).isEqualTo("Test 1.0.0");
assertThat(upgrade.to().getNameAndVersion()).isEqualTo("Test 1.0.1-SNAPSHOT");
assertThat(upgrade.toRelease().getNameAndVersion()).isEqualTo("Test 1.0.1");