Browse Source

Merge branch '3.5.x'

Closes gh-46413
pull/46447/head
Andy Wilkinson 7 months ago
parent
commit
f98492a663
  1. 12
      buildSrc/src/main/java/org/springframework/boot/build/bom/BomExtension.java
  2. 19
      buildSrc/src/main/java/org/springframework/boot/build/bom/Library.java
  3. 7
      buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeDependencies.java
  4. 2
      buildSrc/src/test/java/org/springframework/boot/build/antora/AntoraAsciidocAttributesTests.java
  5. 4
      buildSrc/src/test/java/org/springframework/boot/build/bom/LibraryTests.java
  6. 2
      buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/InteractiveUpgradeResolverTests.java
  7. 4
      buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/UpgradeApplicatorTests.java
  8. 4
      buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/UpgradeTests.java

12
buildSrc/src/main/java/org/springframework/boot/build/bom/BomExtension.java

@ -111,9 +111,9 @@ public class BomExtension { @@ -111,9 +111,9 @@ public class BomExtension {
action.execute(libraryHandler);
LibraryVersion libraryVersion = new LibraryVersion(DependencyVersion.parse(libraryHandler.version));
addLibrary(new Library(name, libraryHandler.calendarName, libraryVersion, libraryHandler.groups,
libraryHandler.prohibitedVersions, libraryHandler.considerSnapshots, versionAlignment(libraryHandler),
libraryHandler.alignWith.dependencyManagementDeclaredIn, libraryHandler.linkRootName,
libraryHandler.links));
libraryHandler.upgradePolicy, libraryHandler.prohibitedVersions, libraryHandler.considerSnapshots,
versionAlignment(libraryHandler), libraryHandler.alignWith.dependencyManagementDeclaredIn,
libraryHandler.linkRootName, libraryHandler.links));
}
private VersionAlignment versionAlignment(LibraryHandler libraryHandler) {
@ -196,6 +196,8 @@ public class BomExtension { @@ -196,6 +196,8 @@ public class BomExtension {
private final List<Group> groups = new ArrayList<>();
private UpgradePolicy upgradePolicy;
private final List<ProhibitedVersion> prohibitedVersions = new ArrayList<>();
private final AlignWithHandler alignWith;
@ -236,6 +238,10 @@ public class BomExtension { @@ -236,6 +238,10 @@ public class BomExtension {
.add(new Group(groupHandler.id, groupHandler.modules, groupHandler.plugins, groupHandler.imports));
}
public void setUpgradePolicy(UpgradePolicy upgradePolicy) {
this.upgradePolicy = upgradePolicy;
}
public void prohibit(Action<ProhibitedHandler> action) {
ProhibitedHandler handler = new ProhibitedHandler();
action.execute(handler);

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

@ -66,6 +66,8 @@ public class Library { @@ -66,6 +66,8 @@ public class Library {
private final String versionProperty;
private final UpgradePolicy upgradePolicy;
private final List<ProhibitedVersion> prohibitedVersions;
private final boolean considerSnapshots;
@ -86,6 +88,8 @@ public class Library { @@ -86,6 +88,8 @@ public class Library {
* be {@code null} in which case the {@code name} is used.
* @param version version of the library
* @param groups groups in the library
* @param upgradePolicy the upgrade policy of the library, or {@code null} to use the
* containing bom's policy
* @param prohibitedVersions version of the library that are prohibited
* @param considerSnapshots whether to consider snapshots
* @param versionAlignment version alignment, if any, for the library
@ -96,14 +100,16 @@ public class Library { @@ -96,14 +100,16 @@ public class Library {
* @param links a list of HTTP links relevant to the library
*/
public Library(String name, String calendarName, LibraryVersion version, List<Group> groups,
List<ProhibitedVersion> prohibitedVersions, boolean considerSnapshots, VersionAlignment versionAlignment,
String alignsWithBom, String linkRootName, Map<String, List<Link>> links) {
UpgradePolicy upgradePolicy, List<ProhibitedVersion> prohibitedVersions, boolean considerSnapshots,
VersionAlignment versionAlignment, String alignsWithBom, String linkRootName,
Map<String, List<Link>> links) {
this.name = name;
this.calendarName = (calendarName != null) ? calendarName : name;
this.version = version;
this.groups = groups;
this.versionProperty = "Spring Boot".equals(name) ? null
: name.toLowerCase(Locale.ENGLISH).replace(' ', '-') + ".version";
this.upgradePolicy = upgradePolicy;
this.prohibitedVersions = prohibitedVersions;
this.considerSnapshots = considerSnapshots;
this.versionAlignment = versionAlignment;
@ -136,6 +142,10 @@ public class Library { @@ -136,6 +142,10 @@ public class Library {
return this.versionProperty;
}
public UpgradePolicy getUpgradePolicy() {
return this.upgradePolicy;
}
public List<ProhibitedVersion> getProhibitedVersions() {
return this.prohibitedVersions;
}
@ -180,8 +190,9 @@ public class Library { @@ -180,8 +190,9 @@ public class Library {
}
public Library withVersion(LibraryVersion version) {
return new Library(this.name, this.calendarName, version, this.groups, this.prohibitedVersions,
this.considerSnapshots, this.versionAlignment, this.alignsWithBom, this.linkRootName, this.links);
return new Library(this.name, this.calendarName, version, this.groups, this.upgradePolicy,
this.prohibitedVersions, this.considerSnapshots, this.versionAlignment, this.alignsWithBom,
this.linkRootName, this.links);
}
/**

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

@ -50,6 +50,7 @@ import org.gradle.api.tasks.options.Option; @@ -50,6 +50,7 @@ import org.gradle.api.tasks.options.Option;
import org.springframework.boot.build.bom.BomExtension;
import org.springframework.boot.build.bom.Library;
import org.springframework.boot.build.bom.UpgradePolicy;
import org.springframework.boot.build.bom.bomr.github.GitHub;
import org.springframework.boot.build.bom.bomr.github.GitHubRepository;
import org.springframework.boot.build.bom.bomr.github.Issue;
@ -264,7 +265,11 @@ public abstract class UpgradeDependencies extends DefaultTask { @@ -264,7 +265,11 @@ public abstract class UpgradeDependencies extends DefaultTask {
}
private boolean compliesWithUpgradePolicy(Library library, DependencyVersion candidate) {
return this.bom.getUpgrade().getPolicy().test(candidate, library.getVersion().getVersion());
UpgradePolicy upgradePolicy = library.getUpgradePolicy();
if (upgradePolicy == null) {
upgradePolicy = this.bom.getUpgrade().getPolicy();
}
return upgradePolicy.test(candidate, library.getVersion().getVersion());
}
private boolean isAnUpgrade(Library library, DependencyVersion candidate) {

2
buildSrc/src/test/java/org/springframework/boot/build/antora/AntoraAsciidocAttributesTests.java

@ -237,7 +237,7 @@ class AntoraAsciidocAttributesTests { @@ -237,7 +237,7 @@ class AntoraAsciidocAttributesTests {
VersionAlignment versionAlignment = null;
String alignsWithBom = null;
String linkRootName = null;
Library library = new Library(name, calendarName, version, groups, prohibitedVersion, considerSnapshots,
Library library = new Library(name, calendarName, version, groups, null, prohibitedVersion, considerSnapshots,
versionAlignment, alignsWithBom, linkRootName, links);
return library;
}

4
buildSrc/src/test/java/org/springframework/boot/build/bom/LibraryTests.java

@ -50,7 +50,7 @@ class LibraryTests { @@ -50,7 +50,7 @@ class LibraryTests {
String alignsWithBom = null;
String linkRootName = null;
Map<String, List<Link>> links = Collections.emptyMap();
Library library = new Library(name, calendarName, version, groups, prohibitedVersion, considerSnapshots,
Library library = new Library(name, calendarName, version, groups, null, prohibitedVersion, considerSnapshots,
versionAlignment, alignsWithBom, linkRootName, links);
assertThat(library.getLinkRootName()).isEqualTo("spring-framework");
}
@ -67,7 +67,7 @@ class LibraryTests { @@ -67,7 +67,7 @@ class LibraryTests {
String alignsWithBom = null;
String linkRootName = "spring-data";
Map<String, List<Link>> links = Collections.emptyMap();
Library library = new Library(name, calendarName, version, groups, prohibitedVersion, considerSnapshots,
Library library = new Library(name, calendarName, version, groups, null, prohibitedVersion, considerSnapshots,
versionAlignment, alignsWithBom, linkRootName, links);
assertThat(library.getLinkRootName()).isEqualTo("spring-data");
}

2
buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/InteractiveUpgradeResolverTests.java

@ -48,7 +48,7 @@ class InteractiveUpgradeResolverTests { @@ -48,7 +48,7 @@ class InteractiveUpgradeResolverTests {
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, false, null, null, null, null);
Library library = new Library("test", null, libraryVersion, null, null, null, false, null, null, null, null);
libraries.add(library);
List<Library> librariesToUpgrade = new ArrayList<>();
librariesToUpgrade.add(library);

4
buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/UpgradeApplicatorTests.java

@ -53,7 +53,7 @@ class UpgradeApplicatorTests { @@ -53,7 +53,7 @@ class UpgradeApplicatorTests {
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, false, null, null, null, Collections.emptyMap());
null, null, false, null, null, null, Collections.emptyMap());
new UpgradeApplicator(bom.toPath(), gradleProperties.toPath())
.apply(new Upgrade(activeMq, activeMq.withVersion(new LibraryVersion(DependencyVersion.parse("5.16")))));
String bomContents = Files.readString(bom.toPath());
@ -67,7 +67,7 @@ class UpgradeApplicatorTests { @@ -67,7 +67,7 @@ class UpgradeApplicatorTests {
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,
false, null, null, null, Collections.emptyMap());
null, false, null, null, null, Collections.emptyMap());
new UpgradeApplicator(bom.toPath(), gradleProperties.toPath())
.apply(new Upgrade(kotlin, kotlin.withVersion(new LibraryVersion(DependencyVersion.parse("1.4")))));
Properties properties = new Properties();

4
buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/UpgradeTests.java

@ -33,7 +33,7 @@ class UpgradeTests { @@ -33,7 +33,7 @@ class UpgradeTests {
@Test
void createToRelease() {
Library from = new Library("Test", null, new LibraryVersion(DependencyVersion.parse("1.0.0")), null, null,
Library from = new Library("Test", null, new LibraryVersion(DependencyVersion.parse("1.0.0")), null, null, null,
false, null, null, null, null);
Upgrade upgrade = new Upgrade(from, from.withVersion(new LibraryVersion(DependencyVersion.parse("1.0.1"))));
assertThat(upgrade.from().getNameAndVersion()).isEqualTo("Test 1.0.0");
@ -43,7 +43,7 @@ class UpgradeTests { @@ -43,7 +43,7 @@ class UpgradeTests {
@Test
void createToSnapshot() {
Library from = new Library("Test", null, new LibraryVersion(DependencyVersion.parse("1.0.0")), null, null,
Library from = new Library("Test", null, new LibraryVersion(DependencyVersion.parse("1.0.0")), null, null, null,
false, null, null, null, null);
Upgrade upgrade = new Upgrade(from,
from.withVersion(new LibraryVersion(DependencyVersion.parse("1.0.1-SNAPSHOT"))),

Loading…
Cancel
Save