[K/N][build] Fix compdb task after Gradle upgrade

This commit is contained in:
Ilya Matveev
2021-09-29 14:44:49 +07:00
committed by TeamCityServer
parent 0cece79856
commit 2a74f63954
@@ -14,6 +14,7 @@ import org.gradle.api.Task
import org.gradle.api.DefaultTask import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.OutputFile import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.getByType import org.gradle.kotlin.dsl.getByType
@@ -53,15 +54,28 @@ internal data class Entry(
} }
open class GenerateCompilationDatabase @Inject constructor(@Input val target: String, open class GenerateCompilationDatabase @Inject constructor(@Input val target: String,
@Input val srcRoot: File, @Internal val srcRoot: File,
@Input val files: Iterable<File>, @Internal val files: Iterable<File>,
@Input val executable: String, @Input val executable: String,
@Input val compilerFlags: List<String>, @Input val compilerFlags: List<String>,
@Input val outputDir: File @Internal val outputDir: File
) : DefaultTask() { ) : DefaultTask() {
@OutputFile @OutputFile
var outputFile = File(outputDir, "compile_commands.json") 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<String>
get() = files.map { it.absolutePath }
@TaskAction @TaskAction
fun run() { fun run() {
val plugin = project.extensions.getByType<ExecClang>() val plugin = project.extensions.getByType<ExecClang>()