@@ -43,10 +43,16 @@ def extensionProps = CheckForbiddenApisExtension.class.declaredFields.findAll{ f
43
43
return Modifier . isPublic(mods) && ! f. synthetic && ! Modifier . isStatic(mods)
44
44
}* . name;
45
45
46
+ // Create a convenience task for all checks (this does not conflict with extension, as it has higher priority in DSL):
47
+ def forbiddenTask = project. tasks. create(FORBIDDEN_APIS_TASK_NAME ) {
48
+ description = " Runs forbidden-apis checks." ;
49
+ group = JavaBasePlugin . VERIFICATION_GROUP ;
50
+ }
51
+
46
52
// Define our tasks (one for each SourceSet):
47
- def forbiddenTasks = project. sourceSets. collect { sourceSet ->
53
+ project. sourceSets. all { sourceSet ->
48
54
def getSourceSetClassesDirs = { sourceSet. output. hasProperty(' classesDirs' ) ? sourceSet. output. classesDirs : project. files(sourceSet. output. classesDir) }
49
- project. tasks. create(sourceSet. getTaskName(FORBIDDEN_APIS_TASK_NAME , null ), CheckForbiddenApis . class) {
55
+ project. tasks. create(sourceSet. getTaskName(FORBIDDEN_APIS_TASK_NAME , null ), CheckForbiddenApis . class) { task ->
50
56
description = " Runs forbidden-apis checks on '${ sourceSet.name} ' classes." ;
51
57
conventionMapping. with{
52
58
extensionProps. each{ key ->
@@ -60,18 +66,12 @@ def forbiddenTasks = project.sourceSets.collect{ sourceSet ->
60
66
project. afterEvaluate{
61
67
def sourceSetDirs = getSourceSetClassesDirs(). files;
62
68
if (classesDirs. any{ sourceSetDirs. contains(it) }) {
63
- dependsOn(sourceSet. output);
69
+ task . dependsOn(sourceSet. output);
64
70
}
65
71
}
72
+ forbiddenTask. dependsOn(task);
66
73
}
67
74
}
68
75
69
- // Create a convenience task for all checks (this does not conflict with extension, as it has higher priority in DSL):
70
- def forbiddenTask = project. tasks. create(FORBIDDEN_APIS_TASK_NAME ) {
71
- description = " Runs forbidden-apis checks." ;
72
- group = JavaBasePlugin . VERIFICATION_GROUP ;
73
- dependsOn(forbiddenTasks);
74
- }
75
-
76
76
// Add our task as dependency to chain
77
77
project. tasks[JavaBasePlugin . CHECK_TASK_NAME ]. dependsOn(forbiddenTask);
0 commit comments