Fixed out-of-process compiler execution if project directy is absent

If project directory does not exist and out-of-process execution is used
the file with compiler arguments should be created in project directory
(if exists) or in temp directory.
#KT-43740 Fixed
This commit is contained in:
Andrey Uskov
2020-12-13 11:40:46 +03:00
parent 9be7221efd
commit 0a2269cccb
@@ -126,8 +126,12 @@ internal fun runToolInSeparateProcess(
}
private fun writeArgumentsToFile(directory: File, argsArray: Array<String>): File {
val compilerOptions =
Files.createTempFile(directory.toPath(), LocalDateTime.now().format(DateTimeFormatter.BASIC_ISO_DATE) + "_", ".compiler.options").toFile()
val prefix = LocalDateTime.now().format(DateTimeFormatter.BASIC_ISO_DATE) + "_"
val suffix = ".compiler.options"
val compilerOptions = if (directory.exists())
Files.createTempFile(directory.toPath(), prefix, suffix).toFile()
else
Files.createTempFile(prefix, suffix).toFile()
compilerOptions.deleteOnExit()
compilerOptions.writeText(argsArray.joinToString(" ") { "\"${StringEscapeUtils.escapeJava(it)}\"" })
return compilerOptions