From baa20e267757e4be76a6ea27616354882c8ed38c Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Wed, 14 Mar 2018 21:16:55 +0300 Subject: [PATCH] Ensure absolute paths are written to module xml file Since d0ca0dca2b76d92957b31ceedbaf1ba583e57a36 first IC build uses CompilationMode.Rebuild instead of Incremental to avoid unnecessary work (computing API difference etc.). However there is a branch that does not transform source files paths to absolute ones before writing them to module xml file. In our plugins we have always transformed files to absolute ones before passing them to IncrementalJvmCompilerRunner, so there is no problem. But third party build systems could pass relative paths to IncrementalJvmCompilerRunner (namely Kobalt does so). It turned out to break builds because KotlinToJVMBytecodeCompiler takes module xml file's (which is a temporary file itself) parent as a base for relative source files (see KotlinToJVMBytecodeCompiler.getAbsolutePaths). This change ensures that makeModuleFile always uses absolute files. #KT-22542 fixed --- .../src/org/jetbrains/kotlin/incremental/buildUtil.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build-common/src/org/jetbrains/kotlin/incremental/buildUtil.kt b/build-common/src/org/jetbrains/kotlin/incremental/buildUtil.kt index 24cbc8b829f..8b50223288a 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/buildUtil.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/buildUtil.kt @@ -47,7 +47,10 @@ fun makeModuleFile( builder.addModule( name, outputDir.absolutePath, - sourcesToCompile, + // important to transform file to absolute paths, + // otherwise compiler will use module file's parent as base path (a temporary file; see below) + // (see org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.getAbsolutePaths) + sourcesToCompile.map { it.absoluteFile }, javaSourceRoots, classpath, null,