Gradle: Fix task property validation issues
This commit is contained in:
committed by
Ilya Matveev
parent
d8c6ad4606
commit
4cb6d11990
+8
-2
@@ -33,7 +33,10 @@ import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.library.SearchPathResolver
|
||||
import java.io.File
|
||||
|
||||
open class KonanLibrariesSpec(val task: KonanArtifactWithLibrariesTask, val project: Project) {
|
||||
open class KonanLibrariesSpec(
|
||||
@Internal val task: KonanArtifactWithLibrariesTask,
|
||||
@Internal val project: Project
|
||||
) {
|
||||
|
||||
@InputFiles val files = mutableSetOf<FileCollection>()
|
||||
|
||||
@@ -50,6 +53,7 @@ open class KonanLibrariesSpec(val task: KonanArtifactWithLibrariesTask, val proj
|
||||
@Input get() = mutableSetOf<File>().apply {
|
||||
addAll(explicitRepos)
|
||||
add(task.destinationDir) // TODO: Check if task is a library - create a Library interface
|
||||
add(task.destinationDir) // TODO: Check if task is a library - create a Library interface
|
||||
add(task.project.konanLibsBaseDir.targetSubdir(target))
|
||||
addAll(artifacts.flatMap { it.libraries.repos })
|
||||
addAll(task.platformConfiguration.files.map { it.parentFile })
|
||||
@@ -59,7 +63,9 @@ open class KonanLibrariesSpec(val task: KonanArtifactWithLibrariesTask, val proj
|
||||
@Internal get() = task.konanTarget
|
||||
|
||||
private val friendsTasks = mutableSetOf<KonanBuildingTask>()
|
||||
val friends:Set<File> get() = mutableSetOf<File>().apply {
|
||||
|
||||
@get:Internal // Taken into account by tasks's dependOn.
|
||||
val friends: Set<File> get() = mutableSetOf<File>().apply {
|
||||
addAll(friendsTasks.map { it.artifact })
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -48,7 +48,12 @@ internal val Project.simpleOsName
|
||||
/** A task with a KonanTarget specified. */
|
||||
abstract class KonanTargetableTask: DefaultTask() {
|
||||
|
||||
@Input internal lateinit var konanTarget: KonanTarget
|
||||
@get:Input
|
||||
val konanTargetName: String
|
||||
get() = konanTarget.name
|
||||
|
||||
@get:Internal
|
||||
internal lateinit var konanTarget: KonanTarget
|
||||
|
||||
internal open fun init(target: KonanTarget) {
|
||||
this.konanTarget = target
|
||||
|
||||
+2
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.gradle.plugin.tasks
|
||||
|
||||
import org.gradle.api.tasks.Console
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.model.KonanModelArtifact
|
||||
@@ -27,6 +28,7 @@ import java.io.File
|
||||
/** Base class for both interop and compiler tasks. */
|
||||
abstract class KonanBuildingTask: KonanArtifactWithLibrariesTask(), KonanBuildingSpec {
|
||||
|
||||
@get:Internal
|
||||
internal abstract val toolRunner: KonanToolRunner
|
||||
internal abstract fun toModelArtifact(): KonanModelArtifact
|
||||
|
||||
|
||||
+7
-5
@@ -36,8 +36,8 @@ import java.io.File
|
||||
*/
|
||||
abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
||||
|
||||
@Internal override val toolRunner =
|
||||
KonanCompilerRunner(project, project.konanExtension.jvmArgs)
|
||||
@get:Internal
|
||||
override val toolRunner = KonanCompilerRunner(project, project.konanExtension.jvmArgs)
|
||||
|
||||
abstract val produce: CompilerOutputKind
|
||||
@Internal get
|
||||
@@ -56,13 +56,13 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
||||
|
||||
@Internal var enableMultiplatform = false
|
||||
|
||||
internal val commonSrcFiles_ = mutableSetOf<FileCollection>()
|
||||
private val commonSrcFiles_ = mutableSetOf<FileCollection>()
|
||||
val commonSrcFiles: Collection<FileCollection>
|
||||
@Internal get() = if (enableMultiplatform) commonSrcFiles_ else emptyList()
|
||||
|
||||
// Other compilation parameters -------------------------------------------
|
||||
|
||||
protected val srcFiles_ = mutableSetOf<FileCollection>()
|
||||
private val srcFiles_ = mutableSetOf<FileCollection>()
|
||||
val srcFiles: Collection<FileCollection>
|
||||
@Internal get() = srcFiles_.takeIf { !it.isEmpty() } ?: listOf(project.konanDefaultSrcFiles)
|
||||
|
||||
@@ -70,7 +70,7 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
||||
@InputFiles get() = listOf(srcFiles, commonSrcFiles).flatten()
|
||||
|
||||
private val allSourceFiles: List<File>
|
||||
@Internal get() = allSources
|
||||
get() = allSources
|
||||
.flatMap { it.files }
|
||||
.filter { it.name.endsWith(".kt") }
|
||||
|
||||
@@ -101,6 +101,7 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
||||
* In regular (one-stage) compilation, sources are directly compiled into a final native binary.
|
||||
* In two-stage compilation, sources are compiled into a klib first and then a final native binary is produced from this klib.
|
||||
*/
|
||||
@get:Input
|
||||
abstract val enableTwoStageCompilation: Boolean
|
||||
|
||||
protected fun directoryToKt(dir: Any) = project.fileTree(dir).apply {
|
||||
@@ -377,6 +378,7 @@ abstract class KonanCompileNativeBinary: KonanCompileTask() {
|
||||
open class KonanCompileProgramTask: KonanCompileNativeBinary() {
|
||||
override val produce: CompilerOutputKind get() = CompilerOutputKind.PROGRAM
|
||||
|
||||
@Internal
|
||||
var runTask: Exec? = null
|
||||
|
||||
inner class RunArgumentProvider(): CommandLineArgumentProvider {
|
||||
|
||||
+4
-3
@@ -22,6 +22,7 @@ import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.gradle.workers.IsolationMode
|
||||
import org.gradle.workers.WorkAction
|
||||
import org.gradle.workers.WorkerExecutor
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.konan.KonanInteropSpec.IncludeDirectoriesSpec
|
||||
@@ -41,10 +42,10 @@ import javax.inject.Inject
|
||||
* A task executing cinterop tool with the given args and compiling the stubs produced by this tool.
|
||||
*/
|
||||
|
||||
open class KonanInteropTask @Inject constructor(val workerExecutor: WorkerExecutor) : KonanBuildingTask(), KonanInteropSpec {
|
||||
open class KonanInteropTask @Inject constructor(@Internal val workerExecutor: WorkerExecutor) : KonanBuildingTask(), KonanInteropSpec {
|
||||
|
||||
@Internal override val toolRunner: KonanToolRunner =
|
||||
KonanInteropRunner(project, project.konanExtension.jvmArgs)
|
||||
@get:Internal
|
||||
override val toolRunner: KonanToolRunner = KonanInteropRunner(project, project.konanExtension.jvmArgs)
|
||||
|
||||
override fun init(config: KonanBuildingConfig<*>, destinationDir: File, artifactName: String, target: KonanTarget) {
|
||||
super.init(config, destinationDir, artifactName, target)
|
||||
|
||||
Reference in New Issue
Block a user