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.DependencyConstraint;
|
||||
import org.gradle.api.artifacts.DependencyConstraintMetadata;
|
||||
import org.gradle.api.artifacts.DependencyConstraintSet;
|
||||
import org.gradle.api.artifacts.dsl.DependencyHandler;
|
||||
import org.gradle.api.tasks.Internal;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.platform.base.Platform;
|
||||
|
||||
import org.springframework.boot.build.bom.BomExtension;
|
||||
import org.springframework.boot.build.bom.BomPlugin;
|
||||
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 List<String> projectPaths = new ArrayList<>();
|
||||
private final List<DependencyConstraintSet> dependencyConstraintSets = new ArrayList<>();
|
||||
|
||||
private final List<BomExtension> boms = new ArrayList<>();
|
||||
|
||||
public ExtractVersionConstraints() {
|
||||
DependencyHandler dependencies = getProject().getDependencies();
|
||||
|
@ -68,7 +72,11 @@ public class ExtractVersionConstraints extends DefaultTask {
|
|||
Dependency project = getProject().getDependencies().project(Map.of("path", projectPath));
|
||||
Dependency dependency = getProject().getDependencies().enforcedPlatform(project);
|
||||
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
|
||||
|
@ -89,12 +97,9 @@ public class ExtractVersionConstraints extends DefaultTask {
|
|||
@TaskAction
|
||||
void extractVersionConstraints() {
|
||||
this.configuration.resolve();
|
||||
for (String projectPath : this.projectPaths) {
|
||||
extractVersionProperties(projectPath);
|
||||
for (DependencyConstraint constraint : getProject().project(projectPath)
|
||||
.getConfigurations()
|
||||
.getByName("apiElements")
|
||||
.getAllDependencyConstraints()) {
|
||||
this.boms.forEach(this::extractVersionProperties);
|
||||
for (DependencyConstraintSet constraints : this.dependencyConstraintSets) {
|
||||
for (DependencyConstraint constraint : constraints) {
|
||||
this.versionConstraints.put(constraint.getGroup() + ":" + constraint.getName(),
|
||||
constraint.getVersionConstraint().toString());
|
||||
this.constrainedVersions.add(new ConstrainedVersion(constraint.getGroup(), constraint.getName(),
|
||||
|
@ -103,9 +108,8 @@ public class ExtractVersionConstraints extends DefaultTask {
|
|||
}
|
||||
}
|
||||
|
||||
private void extractVersionProperties(String projectPath) {
|
||||
BomExtension bom = (BomExtension) getProject().project(projectPath).getExtensions().getByName("bom");
|
||||
for (Library lib : bom.getLibraries()) {
|
||||
private void extractVersionProperties(BomExtension bomExtension) {
|
||||
for (Library lib : bomExtension.getLibraries()) {
|
||||
String versionProperty = lib.getVersionProperty();
|
||||
if (versionProperty != null) {
|
||||
this.versionProperties.add(new VersionProperty(lib.getName(), versionProperty));
|
||||
|
|
Loading…
Reference in New Issue
Block a user