@@ -93,14 +93,15 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
9393 customTasks : Set <AffectedModuleTaskType >
9494 ) {
9595 customTasks.forEach { taskType ->
96- val task = rootProject.tasks.register(taskType.commandByImpact).get()
97- task.group = CUSTOM_TASK_GROUP_NAME
98- task.description = taskType.taskDescription
99- disableConfigCache(task)
100-
101- rootProject.subprojects { project ->
102- pluginIds.forEach { pluginId ->
103- withPlugin(pluginId, task, taskType, project)
96+ rootProject.tasks.register(taskType.commandByImpact) { task ->
97+ task.group = CUSTOM_TASK_GROUP_NAME
98+ task.description = taskType.taskDescription
99+ disableConfigCache(task)
100+
101+ rootProject.subprojects { project ->
102+ pluginIds.forEach { pluginId ->
103+ withPlugin(pluginId, task, taskType, project)
104+ }
104105 }
105106 }
106107 }
@@ -134,20 +135,19 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
134135 taskType : AffectedModuleTaskType ,
135136 groupName : String
136137 ) {
137- val task = rootProject.tasks.register(taskType.commandByImpact).get()
138- task.group = groupName
139- task.description = taskType.taskDescription
140- disableConfigCache(task)
138+ rootProject.tasks.register(taskType.commandByImpact) { task ->
139+ task.group = groupName
140+ task.description = taskType.taskDescription
141+ disableConfigCache(task)
141142
142- rootProject.subprojects { project ->
143- project.afterEvaluate { evaluatedProject ->
143+ rootProject.subprojects { project ->
144144 pluginIds.forEach { pluginId ->
145145 if (pluginId == PLUGIN_JAVA_LIBRARY || pluginId == PLUGIN_KOTLIN ) {
146146 if (taskType == InternalTaskType .ANDROID_JVM_TEST ) {
147- withPlugin(pluginId, task, InternalTaskType .JVM_TEST , evaluatedProject )
147+ withPlugin(pluginId, task, InternalTaskType .JVM_TEST , project )
148148 }
149149 } else {
150- withPlugin(pluginId, task, taskType, evaluatedProject )
150+ withPlugin(pluginId, task, taskType, project )
151151 }
152152 }
153153 }
@@ -172,12 +172,10 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
172172 task.dependsOn(path)
173173 }
174174
175- project.afterEvaluate {
176- project.tasks.findByPath(path)?.onlyIf { task ->
177- when {
178- ! AffectedModuleDetector .isProjectEnabled(task.project) -> true
179- else -> AffectedModuleDetector .isProjectAffected(task.project)
180- }
175+ project.tasks.findByPath(path)?.onlyIf { task ->
176+ when {
177+ ! AffectedModuleDetector .isProjectEnabled(task.project) -> true
178+ else -> AffectedModuleDetector .isProjectAffected(task.project)
181179 }
182180 }
183181 }
0 commit comments