Merge branch '5.8.x' into 6.0.x
This commit is contained in:
commit
602a991971
|
@ -17,10 +17,8 @@
|
||||||
package org.springframework.security.convention.versions;
|
package org.springframework.security.convention.versions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask;
|
import org.gradle.api.DefaultTask;
|
||||||
|
@ -39,31 +37,22 @@ public class VerifyDependenciesVersionsPlugin implements Plugin<Project> {
|
||||||
TaskProvider<VerifyDependenciesVersionsTask> verifyDependenciesVersionsTaskProvider = project.getTasks().register("verifyDependenciesVersions", VerifyDependenciesVersionsTask.class, (task) -> {
|
TaskProvider<VerifyDependenciesVersionsTask> verifyDependenciesVersionsTaskProvider = project.getTasks().register("verifyDependenciesVersions", VerifyDependenciesVersionsTask.class, (task) -> {
|
||||||
task.setGroup("Verification");
|
task.setGroup("Verification");
|
||||||
task.setDescription("Verify that specific dependencies are using the same version");
|
task.setDescription("Verify that specific dependencies are using the same version");
|
||||||
List<Configuration> allConfigurations = new ArrayList<>();
|
List<Configuration> allConfigurations = new ArrayList<>(getConfigurations(project));
|
||||||
allConfigurations.addAll(getConfigurations(project));
|
|
||||||
allConfigurations.addAll(getSubprojectsConfigurations(project.getSubprojects()));
|
|
||||||
task.setConfigurations(allConfigurations);
|
task.setConfigurations(allConfigurations);
|
||||||
});
|
});
|
||||||
project.getTasks().named(JavaBasePlugin.CHECK_TASK_NAME, checkTask -> checkTask.dependsOn(verifyDependenciesVersionsTaskProvider));
|
project.getTasks().named(JavaBasePlugin.CHECK_TASK_NAME, checkTask -> checkTask.dependsOn(verifyDependenciesVersionsTaskProvider));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Configuration> getConfigurations(Project project) {
|
private List<Configuration> getConfigurations(Project rootProject) {
|
||||||
return project.getConfigurations().stream()
|
List<Configuration> configurations = new ArrayList<>();
|
||||||
|
for (Project project : rootProject.getAllprojects()) {
|
||||||
|
List<Configuration> runtimeClasspath = project.getConfigurations().stream()
|
||||||
.filter(Configuration::isCanBeResolved)
|
.filter(Configuration::isCanBeResolved)
|
||||||
.filter((config) -> config.getName().equals("runtimeClasspath"))
|
.filter((config) -> config.getName().equals("runtimeClasspath"))
|
||||||
.toList();
|
.toList();
|
||||||
|
configurations.addAll(runtimeClasspath);
|
||||||
}
|
}
|
||||||
|
return configurations;
|
||||||
private List<Configuration> getSubprojectsConfigurations(Set<Project> subprojects) {
|
|
||||||
if (subprojects.isEmpty()) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
List<Configuration> subprojectConfigurations = new ArrayList<>();
|
|
||||||
for (Project subproject : subprojects) {
|
|
||||||
subprojectConfigurations.addAll(getConfigurations(subproject));
|
|
||||||
subprojectConfigurations.addAll(getSubprojectsConfigurations(subproject.getSubprojects()));
|
|
||||||
}
|
|
||||||
return subprojectConfigurations;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class VerifyDependenciesVersionsTask extends DefaultTask {
|
public static class VerifyDependenciesVersionsTask extends DefaultTask {
|
||||||
|
@ -79,6 +68,10 @@ public class VerifyDependenciesVersionsPlugin implements Plugin<Project> {
|
||||||
Map<String, List<Artifact>> artifacts = getDependencies(this.configurations);
|
Map<String, List<Artifact>> artifacts = getDependencies(this.configurations);
|
||||||
List<Artifact> oauth2OidcSdk = artifacts.get("oauth2-oidc-sdk");
|
List<Artifact> oauth2OidcSdk = artifacts.get("oauth2-oidc-sdk");
|
||||||
List<Artifact> nimbusJoseJwt = artifacts.get("nimbus-jose-jwt");
|
List<Artifact> nimbusJoseJwt = artifacts.get("nimbus-jose-jwt");
|
||||||
|
if (oauth2OidcSdk == null) {
|
||||||
|
// Could not resolve oauth2-oidc-sdk
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (oauth2OidcSdk.size() > 1) {
|
if (oauth2OidcSdk.size() > 1) {
|
||||||
throw new IllegalStateException("Found multiple versions of oauth2-oidc-sdk: " + oauth2OidcSdk);
|
throw new IllegalStateException("Found multiple versions of oauth2-oidc-sdk: " + oauth2OidcSdk);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue