mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Merge branch '3.2.x'
Closes gh-40551
This commit is contained in:
commit
308b0d9921
@ -32,12 +32,14 @@ import org.gradle.api.artifacts.Configuration;
|
|||||||
import org.gradle.api.artifacts.Dependency;
|
import org.gradle.api.artifacts.Dependency;
|
||||||
import org.gradle.api.artifacts.DependencyConstraint;
|
import org.gradle.api.artifacts.DependencyConstraint;
|
||||||
import org.gradle.api.artifacts.DependencyConstraintMetadata;
|
import org.gradle.api.artifacts.DependencyConstraintMetadata;
|
||||||
|
import org.gradle.api.artifacts.DependencyConstraintSet;
|
||||||
import org.gradle.api.artifacts.dsl.DependencyHandler;
|
import org.gradle.api.artifacts.dsl.DependencyHandler;
|
||||||
import org.gradle.api.tasks.Internal;
|
import org.gradle.api.tasks.Internal;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
import org.gradle.platform.base.Platform;
|
import org.gradle.platform.base.Platform;
|
||||||
|
|
||||||
import org.springframework.boot.build.bom.BomExtension;
|
import org.springframework.boot.build.bom.BomExtension;
|
||||||
|
import org.springframework.boot.build.bom.BomPlugin;
|
||||||
import org.springframework.boot.build.bom.Library;
|
import org.springframework.boot.build.bom.Library;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,7 +58,9 @@ public class ExtractVersionConstraints extends DefaultTask {
|
|||||||
|
|
||||||
private final Set<VersionProperty> versionProperties = new TreeSet<>();
|
private final Set<VersionProperty> versionProperties = new TreeSet<>();
|
||||||
|
|
||||||
private final List<String> projectPaths = new ArrayList<>();
|
private final List<DependencyConstraintSet> dependencyConstraintSets = new ArrayList<>();
|
||||||
|
|
||||||
|
private final List<BomExtension> boms = new ArrayList<>();
|
||||||
|
|
||||||
public ExtractVersionConstraints() {
|
public ExtractVersionConstraints() {
|
||||||
DependencyHandler dependencies = getProject().getDependencies();
|
DependencyHandler dependencies = getProject().getDependencies();
|
||||||
@ -68,7 +72,11 @@ public class ExtractVersionConstraints extends DefaultTask {
|
|||||||
Dependency project = getProject().getDependencies().project(Map.of("path", projectPath));
|
Dependency project = getProject().getDependencies().project(Map.of("path", projectPath));
|
||||||
Dependency dependency = getProject().getDependencies().enforcedPlatform(project);
|
Dependency dependency = getProject().getDependencies().enforcedPlatform(project);
|
||||||
this.configuration.getDependencies().add(dependency);
|
this.configuration.getDependencies().add(dependency);
|
||||||
this.projectPaths.add(projectPath);
|
getProject().getPlugins().withType(BomPlugin.class).all((plugin) -> {
|
||||||
|
this.boms.add(getProject().getExtensions().getByType(BomExtension.class));
|
||||||
|
this.dependencyConstraintSets
|
||||||
|
.add(getProject().getConfigurations().getByName("apiElements").getAllDependencyConstraints());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Internal
|
@Internal
|
||||||
@ -89,12 +97,9 @@ public class ExtractVersionConstraints extends DefaultTask {
|
|||||||
@TaskAction
|
@TaskAction
|
||||||
void extractVersionConstraints() {
|
void extractVersionConstraints() {
|
||||||
this.configuration.resolve();
|
this.configuration.resolve();
|
||||||
for (String projectPath : this.projectPaths) {
|
this.boms.forEach(this::extractVersionProperties);
|
||||||
extractVersionProperties(projectPath);
|
for (DependencyConstraintSet constraints : this.dependencyConstraintSets) {
|
||||||
for (DependencyConstraint constraint : getProject().project(projectPath)
|
for (DependencyConstraint constraint : constraints) {
|
||||||
.getConfigurations()
|
|
||||||
.getByName("apiElements")
|
|
||||||
.getAllDependencyConstraints()) {
|
|
||||||
this.versionConstraints.put(constraint.getGroup() + ":" + constraint.getName(),
|
this.versionConstraints.put(constraint.getGroup() + ":" + constraint.getName(),
|
||||||
constraint.getVersionConstraint().toString());
|
constraint.getVersionConstraint().toString());
|
||||||
this.constrainedVersions.add(new ConstrainedVersion(constraint.getGroup(), constraint.getName(),
|
this.constrainedVersions.add(new ConstrainedVersion(constraint.getGroup(), constraint.getName(),
|
||||||
@ -103,9 +108,8 @@ public class ExtractVersionConstraints extends DefaultTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractVersionProperties(String projectPath) {
|
private void extractVersionProperties(BomExtension bomExtension) {
|
||||||
BomExtension bom = (BomExtension) getProject().project(projectPath).getExtensions().getByName("bom");
|
for (Library lib : bomExtension.getLibraries()) {
|
||||||
for (Library lib : bom.getLibraries()) {
|
|
||||||
String versionProperty = lib.getVersionProperty();
|
String versionProperty = lib.getVersionProperty();
|
||||||
if (versionProperty != null) {
|
if (versionProperty != null) {
|
||||||
this.versionProperties.add(new VersionProperty(lib.getName(), versionProperty));
|
this.versionProperties.add(new VersionProperty(lib.getName(), versionProperty));
|
||||||
|
Loading…
Reference in New Issue
Block a user