mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge branch '3.1.x'
Closes gh-37193
This commit is contained in:
commit
809990bc86
@ -113,7 +113,8 @@ public class BomExtension {
|
|||||||
LibraryHandler libraryHandler = objects.newInstance(LibraryHandler.class, (version != null) ? version : "");
|
LibraryHandler libraryHandler = objects.newInstance(LibraryHandler.class, (version != null) ? version : "");
|
||||||
action.execute(libraryHandler);
|
action.execute(libraryHandler);
|
||||||
LibraryVersion libraryVersion = new LibraryVersion(DependencyVersion.parse(libraryHandler.version));
|
LibraryVersion libraryVersion = new LibraryVersion(DependencyVersion.parse(libraryHandler.version));
|
||||||
addLibrary(new Library(name, libraryVersion, libraryHandler.groups, libraryHandler.prohibitedVersions));
|
addLibrary(new Library(name, libraryVersion, libraryHandler.groups, libraryHandler.prohibitedVersions,
|
||||||
|
libraryHandler.considerSnapshots));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void effectiveBomArtifact() {
|
public void effectiveBomArtifact() {
|
||||||
@ -213,6 +214,8 @@ public class BomExtension {
|
|||||||
|
|
||||||
private final List<ProhibitedVersion> prohibitedVersions = new ArrayList<>();
|
private final List<ProhibitedVersion> prohibitedVersions = new ArrayList<>();
|
||||||
|
|
||||||
|
private boolean considerSnapshots = false;
|
||||||
|
|
||||||
private String version;
|
private String version;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -224,6 +227,10 @@ public class BomExtension {
|
|||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void considerSnapshots() {
|
||||||
|
this.considerSnapshots = true;
|
||||||
|
}
|
||||||
|
|
||||||
public void group(String id, Action<GroupHandler> action) {
|
public void group(String id, Action<GroupHandler> action) {
|
||||||
GroupHandler groupHandler = new GroupHandler(id);
|
GroupHandler groupHandler = new GroupHandler(id);
|
||||||
action.execute(groupHandler);
|
action.execute(groupHandler);
|
||||||
|
@ -42,6 +42,8 @@ public class Library {
|
|||||||
|
|
||||||
private final List<ProhibitedVersion> prohibitedVersions;
|
private final List<ProhibitedVersion> prohibitedVersions;
|
||||||
|
|
||||||
|
private final boolean considerSnapshots;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@code Library} with the given {@code name}, {@code version}, and
|
* Create a new {@code Library} with the given {@code name}, {@code version}, and
|
||||||
* {@code groups}.
|
* {@code groups}.
|
||||||
@ -49,15 +51,17 @@ public class Library {
|
|||||||
* @param version version of the library
|
* @param version version of the library
|
||||||
* @param groups groups in the library
|
* @param groups groups in the library
|
||||||
* @param prohibitedVersions version of the library that are prohibited
|
* @param prohibitedVersions version of the library that are prohibited
|
||||||
|
* @param considerSnapshots whether to consider snapshots
|
||||||
*/
|
*/
|
||||||
public Library(String name, LibraryVersion version, List<Group> groups,
|
public Library(String name, LibraryVersion version, List<Group> groups, List<ProhibitedVersion> prohibitedVersions,
|
||||||
List<ProhibitedVersion> prohibitedVersions) {
|
boolean considerSnapshots) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.groups = groups;
|
this.groups = groups;
|
||||||
this.versionProperty = "Spring Boot".equals(name) ? null
|
this.versionProperty = "Spring Boot".equals(name) ? null
|
||||||
: name.toLowerCase(Locale.ENGLISH).replace(' ', '-') + ".version";
|
: name.toLowerCase(Locale.ENGLISH).replace(' ', '-') + ".version";
|
||||||
this.prohibitedVersions = prohibitedVersions;
|
this.prohibitedVersions = prohibitedVersions;
|
||||||
|
this.considerSnapshots = considerSnapshots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -80,6 +84,10 @@ public class Library {
|
|||||||
return this.prohibitedVersions;
|
return this.prohibitedVersions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isConsiderSnapshots() {
|
||||||
|
return this.considerSnapshots;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A version or range of versions that are prohibited from being used in a bom.
|
* A version or range of versions that are prohibited from being used in a bom.
|
||||||
*/
|
*/
|
||||||
|
@ -23,6 +23,7 @@ import javax.inject.Inject;
|
|||||||
import org.gradle.api.Task;
|
import org.gradle.api.Task;
|
||||||
|
|
||||||
import org.springframework.boot.build.bom.BomExtension;
|
import org.springframework.boot.build.bom.BomExtension;
|
||||||
|
import org.springframework.boot.build.bom.Library;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Task} to move to snapshot dependencies.
|
* A {@link Task} to move to snapshot dependencies.
|
||||||
@ -57,4 +58,9 @@ public abstract class MoveToSnapshots extends UpgradeDependencies {
|
|||||||
return snapshotVersion.substring(0, snapshotVersion.length() - "-SNAPSHOT".length());
|
return snapshotVersion.substring(0, snapshotVersion.length() - "-SNAPSHOT".length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean eligible(Library library) {
|
||||||
|
return library.isConsiderSnapshots() && super.eligible(library);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -211,25 +211,27 @@ public abstract class UpgradeDependencies extends DefaultTask {
|
|||||||
new MultithreadedLibraryUpdateResolver(getThreads().get(),
|
new MultithreadedLibraryUpdateResolver(getThreads().get(),
|
||||||
new StandardLibraryUpdateResolver(new MavenMetadataVersionResolver(getRepositoryUris().get()),
|
new StandardLibraryUpdateResolver(new MavenMetadataVersionResolver(getRepositoryUris().get()),
|
||||||
this.bom.getUpgrade().getPolicy())))
|
this.bom.getUpgrade().getPolicy())))
|
||||||
.resolveUpgrades(matchingLibraries(getLibraries().getOrNull()), this.bom.getLibraries());
|
.resolveUpgrades(matchingLibraries(), this.bom.getLibraries());
|
||||||
return upgrades;
|
return upgrades;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Library> matchingLibraries(String pattern) {
|
private List<Library> matchingLibraries() {
|
||||||
if (pattern == null) {
|
List<Library> matchingLibraries = this.bom.getLibraries().stream().filter(this::eligible).toList();
|
||||||
return this.bom.getLibraries();
|
|
||||||
}
|
|
||||||
Predicate<String> libraryPredicate = Pattern.compile(pattern).asPredicate();
|
|
||||||
List<Library> matchingLibraries = this.bom.getLibraries()
|
|
||||||
.stream()
|
|
||||||
.filter((library) -> libraryPredicate.test(library.getName()))
|
|
||||||
.toList();
|
|
||||||
if (matchingLibraries.isEmpty()) {
|
if (matchingLibraries.isEmpty()) {
|
||||||
throw new InvalidUserDataException("No libraries matched '" + pattern + "'");
|
throw new InvalidUserDataException("No libraries to upgrade");
|
||||||
}
|
}
|
||||||
return matchingLibraries;
|
return matchingLibraries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean eligible(Library library) {
|
||||||
|
String pattern = getLibraries().getOrNull();
|
||||||
|
if (pattern == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Predicate<String> libraryPredicate = Pattern.compile(pattern).asPredicate();
|
||||||
|
return libraryPredicate.test(library.getName());
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract String issueTitle(Upgrade upgrade);
|
protected abstract String issueTitle(Upgrade upgrade);
|
||||||
|
|
||||||
protected abstract String commitMessage(Upgrade upgrade, int issueNumber);
|
protected abstract String commitMessage(Upgrade upgrade, int issueNumber);
|
||||||
|
@ -51,9 +51,9 @@ class UpgradeApplicatorTests {
|
|||||||
String originalContents = Files.readString(bom.toPath());
|
String originalContents = Files.readString(bom.toPath());
|
||||||
File gradleProperties = new File(this.temp, "gradle.properties");
|
File gradleProperties = new File(this.temp, "gradle.properties");
|
||||||
FileCopyUtils.copy(new File("src/test/resources/gradle.properties"), gradleProperties);
|
FileCopyUtils.copy(new File("src/test/resources/gradle.properties"), gradleProperties);
|
||||||
new UpgradeApplicator(bom.toPath(), gradleProperties.toPath()).apply(
|
new UpgradeApplicator(bom.toPath(), gradleProperties.toPath()).apply(new Upgrade(
|
||||||
new Upgrade(new Library("ActiveMQ", new LibraryVersion(DependencyVersion.parse("5.15.11")), null, null),
|
new Library("ActiveMQ", new LibraryVersion(DependencyVersion.parse("5.15.11")), null, null, false),
|
||||||
DependencyVersion.parse("5.16")));
|
DependencyVersion.parse("5.16")));
|
||||||
String bomContents = Files.readString(bom.toPath());
|
String bomContents = Files.readString(bom.toPath());
|
||||||
assertThat(bomContents).hasSize(originalContents.length() - 3);
|
assertThat(bomContents).hasSize(originalContents.length() - 3);
|
||||||
}
|
}
|
||||||
@ -64,9 +64,9 @@ class UpgradeApplicatorTests {
|
|||||||
FileCopyUtils.copy(new File("src/test/resources/bom.gradle"), bom);
|
FileCopyUtils.copy(new File("src/test/resources/bom.gradle"), bom);
|
||||||
File gradleProperties = new File(this.temp, "gradle.properties");
|
File gradleProperties = new File(this.temp, "gradle.properties");
|
||||||
FileCopyUtils.copy(new File("src/test/resources/gradle.properties"), gradleProperties);
|
FileCopyUtils.copy(new File("src/test/resources/gradle.properties"), gradleProperties);
|
||||||
new UpgradeApplicator(bom.toPath(), gradleProperties.toPath())
|
new UpgradeApplicator(bom.toPath(), gradleProperties.toPath()).apply(new Upgrade(
|
||||||
.apply(new Upgrade(new Library("Kotlin", new LibraryVersion(DependencyVersion.parse("1.3.70")), null, null),
|
new Library("Kotlin", new LibraryVersion(DependencyVersion.parse("1.3.70")), null, null, false),
|
||||||
DependencyVersion.parse("1.4")));
|
DependencyVersion.parse("1.4")));
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
try (InputStream in = new FileInputStream(gradleProperties)) {
|
try (InputStream in = new FileInputStream(gradleProperties)) {
|
||||||
properties.load(in);
|
properties.load(in);
|
||||||
|
@ -989,6 +989,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Micrometer", "1.12.0-M2") {
|
library("Micrometer", "1.12.0-M2") {
|
||||||
|
considerSnapshots()
|
||||||
group("io.micrometer") {
|
group("io.micrometer") {
|
||||||
modules = [
|
modules = [
|
||||||
"micrometer-registry-stackdriver" {
|
"micrometer-registry-stackdriver" {
|
||||||
@ -1001,6 +1002,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Micrometer Tracing", "1.2.0-M2") {
|
library("Micrometer Tracing", "1.2.0-M2") {
|
||||||
|
considerSnapshots()
|
||||||
group("io.micrometer") {
|
group("io.micrometer") {
|
||||||
imports = [
|
imports = [
|
||||||
"micrometer-tracing-bom"
|
"micrometer-tracing-bom"
|
||||||
@ -1145,6 +1147,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("R2DBC H2", "1.0.0.RELEASE") {
|
library("R2DBC H2", "1.0.0.RELEASE") {
|
||||||
|
considerSnapshots()
|
||||||
group("io.r2dbc") {
|
group("io.r2dbc") {
|
||||||
modules = [
|
modules = [
|
||||||
"r2dbc-h2"
|
"r2dbc-h2"
|
||||||
@ -1173,6 +1176,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("R2DBC Pool", "1.0.1.RELEASE") {
|
library("R2DBC Pool", "1.0.1.RELEASE") {
|
||||||
|
considerSnapshots()
|
||||||
group("io.r2dbc") {
|
group("io.r2dbc") {
|
||||||
modules = [
|
modules = [
|
||||||
"r2dbc-pool"
|
"r2dbc-pool"
|
||||||
@ -1180,6 +1184,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("R2DBC Postgresql", "1.0.2.RELEASE") {
|
library("R2DBC Postgresql", "1.0.2.RELEASE") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.postgresql") {
|
group("org.postgresql") {
|
||||||
modules = [
|
modules = [
|
||||||
"r2dbc-postgresql"
|
"r2dbc-postgresql"
|
||||||
@ -1187,6 +1192,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("R2DBC Proxy", "1.1.2.RELEASE") {
|
library("R2DBC Proxy", "1.1.2.RELEASE") {
|
||||||
|
considerSnapshots()
|
||||||
group("io.r2dbc") {
|
group("io.r2dbc") {
|
||||||
modules = [
|
modules = [
|
||||||
"r2dbc-proxy"
|
"r2dbc-proxy"
|
||||||
@ -1194,6 +1200,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("R2DBC SPI", "1.0.0.RELEASE") {
|
library("R2DBC SPI", "1.0.0.RELEASE") {
|
||||||
|
considerSnapshots()
|
||||||
group("io.r2dbc") {
|
group("io.r2dbc") {
|
||||||
modules = [
|
modules = [
|
||||||
"r2dbc-spi"
|
"r2dbc-spi"
|
||||||
@ -1222,6 +1229,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Reactor Bom", "2023.0.0-M2") {
|
library("Reactor Bom", "2023.0.0-M2") {
|
||||||
|
considerSnapshots()
|
||||||
group("io.projectreactor") {
|
group("io.projectreactor") {
|
||||||
imports = [
|
imports = [
|
||||||
"reactor-bom"
|
"reactor-bom"
|
||||||
@ -1385,6 +1393,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring AMQP", "3.0.8") {
|
library("Spring AMQP", "3.0.8") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.springframework.amqp") {
|
group("org.springframework.amqp") {
|
||||||
imports = [
|
imports = [
|
||||||
"spring-amqp-bom"
|
"spring-amqp-bom"
|
||||||
@ -1392,6 +1401,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring Authorization Server", "1.1.2") {
|
library("Spring Authorization Server", "1.1.2") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.springframework.security") {
|
group("org.springframework.security") {
|
||||||
modules = [
|
modules = [
|
||||||
"spring-security-oauth2-authorization-server"
|
"spring-security-oauth2-authorization-server"
|
||||||
@ -1399,6 +1409,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring Batch", "5.1.0-M2") {
|
library("Spring Batch", "5.1.0-M2") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.springframework.batch") {
|
group("org.springframework.batch") {
|
||||||
imports = [
|
imports = [
|
||||||
"spring-batch-bom"
|
"spring-batch-bom"
|
||||||
@ -1406,6 +1417,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring Data Bom", "2023.1.0-M2") {
|
library("Spring Data Bom", "2023.1.0-M2") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.springframework.data") {
|
group("org.springframework.data") {
|
||||||
imports = [
|
imports = [
|
||||||
"spring-data-bom"
|
"spring-data-bom"
|
||||||
@ -1413,6 +1425,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring Framework", "${springFrameworkVersion}") {
|
library("Spring Framework", "${springFrameworkVersion}") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.springframework") {
|
group("org.springframework") {
|
||||||
imports = [
|
imports = [
|
||||||
"spring-framework-bom"
|
"spring-framework-bom"
|
||||||
@ -1420,6 +1433,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring GraphQL", "1.2.2") {
|
library("Spring GraphQL", "1.2.2") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.springframework.graphql") {
|
group("org.springframework.graphql") {
|
||||||
modules = [
|
modules = [
|
||||||
"spring-graphql",
|
"spring-graphql",
|
||||||
@ -1428,6 +1442,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring HATEOAS", "2.2.0-M2") {
|
library("Spring HATEOAS", "2.2.0-M2") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.springframework.hateoas") {
|
group("org.springframework.hateoas") {
|
||||||
modules = [
|
modules = [
|
||||||
"spring-hateoas"
|
"spring-hateoas"
|
||||||
@ -1435,6 +1450,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring Integration", "6.2.0-M2") {
|
library("Spring Integration", "6.2.0-M2") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.springframework.integration") {
|
group("org.springframework.integration") {
|
||||||
imports = [
|
imports = [
|
||||||
"spring-integration-bom"
|
"spring-integration-bom"
|
||||||
@ -1442,6 +1458,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring Kafka", "3.0.10") {
|
library("Spring Kafka", "3.0.10") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.springframework.kafka") {
|
group("org.springframework.kafka") {
|
||||||
modules = [
|
modules = [
|
||||||
"spring-kafka",
|
"spring-kafka",
|
||||||
@ -1450,6 +1467,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring LDAP", "3.2.0-M2") {
|
library("Spring LDAP", "3.2.0-M2") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.springframework.ldap") {
|
group("org.springframework.ldap") {
|
||||||
modules = [
|
modules = [
|
||||||
"spring-ldap-core",
|
"spring-ldap-core",
|
||||||
@ -1460,6 +1478,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring RESTDocs", "3.0.0") {
|
library("Spring RESTDocs", "3.0.0") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.springframework.restdocs") {
|
group("org.springframework.restdocs") {
|
||||||
imports = [
|
imports = [
|
||||||
"spring-restdocs-bom"
|
"spring-restdocs-bom"
|
||||||
@ -1467,6 +1486,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring Retry", "2.0.2") {
|
library("Spring Retry", "2.0.2") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.springframework.retry") {
|
group("org.springframework.retry") {
|
||||||
modules = [
|
modules = [
|
||||||
"spring-retry"
|
"spring-retry"
|
||||||
@ -1474,6 +1494,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring Security", "6.2.0-M2") {
|
library("Spring Security", "6.2.0-M2") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.springframework.security") {
|
group("org.springframework.security") {
|
||||||
imports = [
|
imports = [
|
||||||
"spring-security-bom"
|
"spring-security-bom"
|
||||||
@ -1481,6 +1502,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring Session", "3.2.0-M1") {
|
library("Spring Session", "3.2.0-M1") {
|
||||||
|
considerSnapshots()
|
||||||
prohibit {
|
prohibit {
|
||||||
startsWith(["Apple-", "Bean-", "Corn-", "Dragonfruit-"])
|
startsWith(["Apple-", "Bean-", "Corn-", "Dragonfruit-"])
|
||||||
because "Spring Session switched to numeric version numbers"
|
because "Spring Session switched to numeric version numbers"
|
||||||
@ -1492,6 +1514,7 @@ bom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Spring WS", "4.0.5") {
|
library("Spring WS", "4.0.5") {
|
||||||
|
considerSnapshots()
|
||||||
group("org.springframework.ws") {
|
group("org.springframework.ws") {
|
||||||
imports = [
|
imports = [
|
||||||
"spring-ws-bom"
|
"spring-ws-bom"
|
||||||
|
Loading…
Reference in New Issue
Block a user