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.
This commit is contained in:
Alexey Tsvetkov
2019-01-17 23:03:09 +03:00
parent f58acbeef5
commit 12e481192a
2 changed files with 8 additions and 1 deletions
@@ -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")
@@ -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