Don't create build directory for task in getter
Since the property is public, it can be invoked from outside,
possibly trough other properties.
This can lead to unwanted side effects: we can create taskBuildDirectory,
because some other task reads the property in parallel with 'clean' task
in current project.
That's exactly what happened when we referenced the property from
'GradleCompilerRunner#buildModulesInfo'.
#KT-24938 fixed
This commit is contained in:
+3
-1
@@ -111,9 +111,10 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
|
||||
cacheOnlyIfEnabledForKotlin()
|
||||
}
|
||||
|
||||
// avoid creating directory in getter: this can lead to failure in parallel build
|
||||
@get:LocalState
|
||||
internal val taskBuildDirectory: File
|
||||
get() = File(File(project.buildDir, KOTLIN_BUILD_DIR_NAME), name).apply { mkdirs() }
|
||||
get() = File(File(project.buildDir, KOTLIN_BUILD_DIR_NAME), name)
|
||||
|
||||
// indicates that task should compile kotlin incrementally if possible
|
||||
// it's not possible when IncrementalTaskInputs#isIncremental returns false (i.e first build)
|
||||
@@ -249,6 +250,7 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
|
||||
|
||||
sourceRoots.log(this.name, logger)
|
||||
val args = prepareCompilerArguments()
|
||||
taskBuildDirectory.mkdirs()
|
||||
callCompiler(args, sourceRoots, ChangedFiles(inputs))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user