@@ -90,14 +90,15 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
9090 customTasks : Set <AffectedModuleTaskType >
9191 ) {
9292 customTasks.forEach { taskType ->
93- val task = rootProject.tasks.register(taskType.commandByImpact).get()
94- task.group = CUSTOM_TASK_GROUP_NAME
95- task.description = taskType.taskDescription
96- disableConfigCache(task)
97-
98- rootProject.subprojects { project ->
99- pluginIds.forEach { pluginId ->
100- withPlugin(pluginId, task, taskType, project)
93+ rootProject.tasks.register(taskType.commandByImpact) { task ->
94+ task.group = CUSTOM_TASK_GROUP_NAME
95+ task.description = taskType.taskDescription
96+ disableConfigCache(task)
97+
98+ rootProject.subprojects { project ->
99+ pluginIds.forEach { pluginId ->
100+ withPlugin(pluginId, task, taskType, project)
101+ }
101102 }
102103 }
103104 }
@@ -131,20 +132,19 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
131132 taskType : AffectedModuleTaskType ,
132133 groupName : String
133134 ) {
134- val task = rootProject.tasks.register(taskType.commandByImpact).get()
135- task.group = groupName
136- task.description = taskType.taskDescription
137- disableConfigCache(task)
135+ rootProject.tasks.register(taskType.commandByImpact) { task ->
136+ task.group = groupName
137+ task.description = taskType.taskDescription
138+ disableConfigCache(task)
138139
139- rootProject.subprojects { project ->
140- project.afterEvaluate { evaluatedProject ->
140+ rootProject.subprojects { project ->
141141 pluginIds.forEach { pluginId ->
142142 if (pluginId == PLUGIN_JAVA_LIBRARY || pluginId == PLUGIN_KOTLIN ) {
143143 if (taskType == InternalTaskType .ANDROID_JVM_TEST ) {
144- withPlugin(pluginId, task, InternalTaskType .JVM_TEST , evaluatedProject )
144+ withPlugin(pluginId, task, InternalTaskType .JVM_TEST , project )
145145 }
146146 } else {
147- withPlugin(pluginId, task, taskType, evaluatedProject )
147+ withPlugin(pluginId, task, taskType, project )
148148 }
149149 }
150150 }
@@ -175,12 +175,10 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
175175 task.dependsOn(path)
176176 }
177177
178- project.afterEvaluate {
179- project.tasks.findByPath(path)?.onlyIf { task ->
180- when {
181- ! AffectedModuleDetector .isProjectEnabled(task.project) -> true
182- else -> AffectedModuleDetector .isProjectAffected(task.project)
183- }
178+ project.tasks.findByPath(path)?.onlyIf { task ->
179+ when {
180+ ! AffectedModuleDetector .isProjectEnabled(task.project) -> true
181+ else -> AffectedModuleDetector .isProjectAffected(task.project)
184182 }
185183 }
186184 }
0 commit comments