From 5bffef6de7d4ef13cf9962d75ade94f0657641a6 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Fri, 15 Dec 2017 16:26:54 +0300 Subject: [PATCH] Allow customizing directory for temporary module files --- .../jps/build/KotlinBuilderModuleScriptGenerator.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilderModuleScriptGenerator.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilderModuleScriptGenerator.kt index 4abbb704ef6..04b2855d212 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilderModuleScriptGenerator.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilderModuleScriptGenerator.kt @@ -139,17 +139,24 @@ object KotlinBuilderModuleScriptGenerator { append("-test") } } + val dir = System.getProperty("kotlin.jps.dir.for.module.files")?.let { File(it) }?.takeIf { it.isDirectory } return try { - File.createTempFile("kjps", readableSuffix + ".script.xml") + File.createTempFile("kjps", readableSuffix + ".script.xml", dir) } catch (e: IOException) { // sometimes files cannot be created, because file name is too long (Windows, Mac OS) // see https://bugs.openjdk.java.net/browse/JDK-8148023 try { - File.createTempFile("kjps", ".script.xml") + File.createTempFile("kjps", ".script.xml", dir) } catch (e: IOException) { - throw RuntimeException("Could not create module file when building $chunk", e) + val message = buildString { + append("Could not create module file when building chunk $chunk") + if (dir != null) { + append(" in dir $dir") + } + } + throw RuntimeException(message, e) } } }