From 0f54e2aa278581e4d274f9dc39d92acce13c81b0 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Thu, 8 Apr 2021 22:22:17 +0800 Subject: [PATCH] Fix https://github.com/mamoe/mirai/pull/1167#discussion_r608537316 (#1174) --- .../src/main/kotlin/postktcompile/PostKotlinCompile.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/kotlin/postktcompile/PostKotlinCompile.kt b/buildSrc/src/main/kotlin/postktcompile/PostKotlinCompile.kt index ec5e9d71f..e5915b9ec 100644 --- a/buildSrc/src/main/kotlin/postktcompile/PostKotlinCompile.kt +++ b/buildSrc/src/main/kotlin/postktcompile/PostKotlinCompile.kt @@ -71,6 +71,7 @@ object PostKotlinCompile { } fun registerForAll(rootProject: Project) { + val checkEnabled = rootProject.hasProperty("mirai.pkc.check.enable") val validator = rootProject.file("binary-compatibility-validator/kt-compile-edit") rootProject.subprojects { val subp: Project = this@subprojects @@ -92,9 +93,11 @@ object PostKotlinCompile { val diff = DiffUtils.generateUnifiedDiff(logFile.name, logFile.name + ".rebuild", oldLog, patch, 3) logFile.parentFile.mkdirs() - logFile.writeText(newLog.joinToString("\n", postfix = "\n")) + if (checkEnabled || newLog.isNotEmpty()) { // Kotlin classes not recompiled. + logFile.writeText(newLog.joinToString("\n", postfix = "\n")) + } val diffMsg = diff.joinToString("\n") - if (rootProject.hasProperty("mirai.pkc.check.enable")) { + if (checkEnabled) { error(diffMsg) } else { println(diffMsg) @@ -103,4 +106,4 @@ object PostKotlinCompile { } } } -} \ No newline at end of file +}