From a7f57646bf55aff3dcfd8f2c313e1ced36c2e9a5 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Wed, 9 Sep 2020 19:49:19 +0300 Subject: [PATCH] Prevent rebuilding by avoid registering doFirst on source tasks (KTI-324) Do the check for empty directories at the build end instead. Registering doFirst makes constant recompile when switching from Kotlin to Kotlin Native composite with the reason: ``` The task was not up-to-date because of the following reasons: One or more additional actions for task ':kotlin:kotlin-stdlib-common:compileKotlinCommon' have changed. ``` Exact reason why actions are different is not clear (there's a single action in both builds in comparison), but probably the reason in different types due to usage of composite build. #KTI-324 Fixed --- build.gradle.kts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 70c5a737ead..d9a28f35230 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -465,16 +465,6 @@ allprojects { outputs.doNotCacheIf("https://youtrack.jetbrains.com/issue/KT-37089") { true } } - tasks.withType().configureEach { - doFirst { - source.visit { - if (file.isDirectory && file.listFiles()?.isEmpty() == true) { - logger.warn("Empty source directories may cause build cache misses: " + file.absolutePath) - } - } - } - } - normalization { runtimeClasspath { ignore("META-INF/MANIFEST.MF") @@ -534,6 +524,22 @@ allprojects { } } +gradle.buildFinished { + val taskGraph = gradle?.taskGraph + if (taskGraph != null) { + taskGraph.allTasks + .filterIsInstance() + .filter { it.didWork } + .forEach { + it.source.visit { + if (file.isDirectory && file.listFiles()?.isEmpty() == true) { + logger.warn("Empty source directories may cause build cache misses: " + file.absolutePath) + } + } + } + } +} + gradle.taskGraph.whenReady { fun Boolean.toOnOff(): String = if (this) "on" else "off" val profile = if (isTeamcityBuild) "CI" else "Local"