17
17
package org .springframework .security .convention .versions ;
18
18
19
19
import java .util .ArrayList ;
20
- import java .util .Collections ;
21
20
import java .util .List ;
22
21
import java .util .Map ;
23
- import java .util .Set ;
24
22
import java .util .stream .Collectors ;
25
23
26
24
import org .gradle .api .DefaultTask ;
@@ -39,31 +37,22 @@ public void apply(Project project) {
39
37
TaskProvider <VerifyDependenciesVersionsTask > verifyDependenciesVersionsTaskProvider = project .getTasks ().register ("verifyDependenciesVersions" , VerifyDependenciesVersionsTask .class , (task ) -> {
40
38
task .setGroup ("Verification" );
41
39
task .setDescription ("Verify that specific dependencies are using the same version" );
42
- List <Configuration > allConfigurations = new ArrayList <>();
43
- allConfigurations .addAll (getConfigurations (project ));
44
- allConfigurations .addAll (getSubprojectsConfigurations (project .getSubprojects ()));
40
+ List <Configuration > allConfigurations = new ArrayList <>(getConfigurations (project ));
45
41
task .setConfigurations (allConfigurations );
46
42
});
47
43
project .getTasks ().named (JavaBasePlugin .CHECK_TASK_NAME , checkTask -> checkTask .dependsOn (verifyDependenciesVersionsTaskProvider ));
48
44
}
49
45
50
- private List <Configuration > getConfigurations (Project project ) {
51
- return project .getConfigurations ().stream ()
52
- .filter (Configuration ::isCanBeResolved )
53
- .filter ((config ) -> config .getName ().equals ("runtimeClasspath" ))
54
- .collect (Collectors .toList ());
55
- }
56
-
57
- private List <Configuration > getSubprojectsConfigurations (Set <Project > subprojects ) {
58
- if (subprojects .isEmpty ()) {
59
- return Collections .emptyList ();
60
- }
61
- List <Configuration > subprojectConfigurations = new ArrayList <>();
62
- for (Project subproject : subprojects ) {
63
- subprojectConfigurations .addAll (getConfigurations (subproject ));
64
- subprojectConfigurations .addAll (getSubprojectsConfigurations (subproject .getSubprojects ()));
46
+ private List <Configuration > getConfigurations (Project rootProject ) {
47
+ List <Configuration > configurations = new ArrayList <>();
48
+ for (Project project : rootProject .getAllprojects ()) {
49
+ List <Configuration > runtimeClasspath = project .getConfigurations ().stream ()
50
+ .filter (Configuration ::isCanBeResolved )
51
+ .filter ((config ) -> config .getName ().equals ("runtimeClasspath" ))
52
+ .collect (Collectors .toList ());
53
+ configurations .addAll (runtimeClasspath );
65
54
}
66
- return subprojectConfigurations ;
55
+ return configurations ;
67
56
}
68
57
69
58
public static class VerifyDependenciesVersionsTask extends DefaultTask {
@@ -79,6 +68,10 @@ public void verify() {
79
68
Map <String , List <Artifact >> artifacts = getDependencies (this .configurations );
80
69
List <Artifact > oauth2OidcSdk = artifacts .get ("oauth2-oidc-sdk" );
81
70
List <Artifact > nimbusJoseJwt = artifacts .get ("nimbus-jose-jwt" );
71
+ if (oauth2OidcSdk == null ) {
72
+ // Could not resolve oauth2-oidc-sdk
73
+ return ;
74
+ }
82
75
if (oauth2OidcSdk .size () > 1 ) {
83
76
throw new IllegalStateException ("Found multiple versions of oauth2-oidc-sdk: " + oauth2OidcSdk );
84
77
}
0 commit comments