From 12e481192a030a82b3c011c1b446b17dbc27cb1a Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Thu, 17 Jan 2019 23:03:09 +0300 Subject: [PATCH] Don't use project root as working directory for Kotlin daemon On windows using a project's root as a working directory for the daemon seems to prevent removing the directory when the daemon runs. Different projects may share an instance of the daemon, so the issue will be present only in a project which started the daemon. --- .../jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt | 2 ++ .../org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt b/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt index 2fa802240ea..5b85b279eff 100644 --- a/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt +++ b/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt @@ -379,6 +379,8 @@ object KotlinCompilerClient { reportingTargets.report(DaemonReportCategory.DEBUG, "starting the daemon as: " + args.joinToString(" ")) val processBuilder = ProcessBuilder(args) processBuilder.redirectErrorStream(true) + val workingDir = File(daemonOptions.runFilesPath).apply { mkdirs() } + processBuilder.directory(workingDir) // assuming daemon process is deaf and (mostly) silent, so do not handle streams val daemon = launchProcessWithFallback(processBuilder, reportingTargets, "daemon client") diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt index 99b4a0e737f..1e38c77bc00 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt @@ -64,7 +64,12 @@ class KotlinGradleIT : BaseGradleIT() { val wd2 = createTempDir("testRunningInDifferentDir") wd1.copyRecursively(wd2) wd1.deleteRecursively() - assert(!wd1.exists()) + if (wd1.exists()) { + val files = buildString { + wd1.walk().forEach { appendln(" " + it.relativeTo(wd1).path) } + } + error("Some files in $wd1 were not removed:\n$files") + } wd0.setWritable(false) workingDir = wd2