Skip to content

Commit a401ff8

Browse files
committed
Improve Bomr's upgrade suggestions for milestones and RCs
Closes gh-34307
1 parent add78d4 commit a401ff8

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/MavenMetadataVersionResolver.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,18 @@ final class MavenMetadataVersionResolver implements VersionResolver {
5858

5959
MavenMetadataVersionResolver(RestTemplate restTemplate, Collection<URI> repositoryUrls) {
6060
this.rest = restTemplate;
61-
this.repositoryUrls = repositoryUrls;
61+
this.repositoryUrls = normalize(repositoryUrls);
62+
}
63+
64+
private Collection<URI> normalize(Collection<URI> uris) {
65+
return uris.stream().map(this::normalize).toList();
66+
}
67+
68+
private URI normalize(URI uri) {
69+
if ("/".equals(uri.getPath())) {
70+
return uri;
71+
}
72+
return URI.create(uri.toString() + "/");
6273
}
6374

6475
@Override

buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/ArtifactVersionDependencyVersion.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -75,6 +75,20 @@ private boolean isSameMinorAndNewerThan(ArtifactVersionDependencyVersion other)
7575
&& isNewerThan(other);
7676
}
7777

78+
@Override
79+
public int compareTo(DependencyVersion other) {
80+
if (other instanceof ArtifactVersionDependencyVersion otherArtifactDependencyVersion) {
81+
ArtifactVersion otherArtifactVersion = otherArtifactDependencyVersion.artifactVersion;
82+
if ("snapshot".equalsIgnoreCase(otherArtifactVersion.getQualifier())
83+
&& otherArtifactVersion.getMajorVersion() == this.artifactVersion.getMajorVersion()
84+
&& otherArtifactVersion.getMinorVersion() == this.artifactVersion.getMinorVersion()
85+
&& otherArtifactVersion.getIncrementalVersion() == this.artifactVersion.getIncrementalVersion()) {
86+
return 1;
87+
}
88+
}
89+
return super.compareTo(other);
90+
}
91+
7892
@Override
7993
public String toString() {
8094
return this.artifactVersion.toString();

0 commit comments

Comments
 (0)