From 2a74f639540989cf4fd45e676204d9c27041f6f4 Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Wed, 29 Sep 2021 14:44:49 +0700 Subject: [PATCH] [K/N][build] Fix compdb task after Gradle upgrade --- .../jetbrains/kotlin/CompilationDatabase.kt | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/CompilationDatabase.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/CompilationDatabase.kt index e54abc1eebb..bf6bfbb3f7f 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/CompilationDatabase.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/CompilationDatabase.kt @@ -14,6 +14,7 @@ import org.gradle.api.Task import org.gradle.api.DefaultTask import org.gradle.api.tasks.Input import org.gradle.api.tasks.InputFiles +import org.gradle.api.tasks.Internal import org.gradle.api.tasks.OutputFile import org.gradle.api.tasks.TaskAction import org.gradle.kotlin.dsl.getByType @@ -53,15 +54,28 @@ internal data class Entry( } open class GenerateCompilationDatabase @Inject constructor(@Input val target: String, - @Input val srcRoot: File, - @Input val files: Iterable, + @Internal val srcRoot: File, + @Internal val files: Iterable, @Input val executable: String, @Input val compilerFlags: List, - @Input val outputDir: File + @Internal val outputDir: File ) : DefaultTask() { @OutputFile var outputFile = File(outputDir, "compile_commands.json") + // Annotate as an input because this path affects the content of the generated file. + @get:Input + val outputDirPath: String + get() = outputDir.absolutePath + + @get:Input + val srcRootPath: String + get() = srcRoot.absolutePath + + @get:Input + val pathsToFiles: Iterable + get() = files.map { it.absolutePath } + @TaskAction fun run() { val plugin = project.extensions.getByType()