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 org.jetbrains.kotlin.library.SearchPathResolver
|
||||||
import java.io.File
|
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>()
|
@InputFiles val files = mutableSetOf<FileCollection>()
|
||||||
|
|
||||||
@@ -50,6 +53,7 @@ open class KonanLibrariesSpec(val task: KonanArtifactWithLibrariesTask, val proj
|
|||||||
@Input get() = mutableSetOf<File>().apply {
|
@Input get() = mutableSetOf<File>().apply {
|
||||||
addAll(explicitRepos)
|
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.destinationDir) // TODO: Check if task is a library - create a Library interface
|
||||||
add(task.project.konanLibsBaseDir.targetSubdir(target))
|
add(task.project.konanLibsBaseDir.targetSubdir(target))
|
||||||
addAll(artifacts.flatMap { it.libraries.repos })
|
addAll(artifacts.flatMap { it.libraries.repos })
|
||||||
addAll(task.platformConfiguration.files.map { it.parentFile })
|
addAll(task.platformConfiguration.files.map { it.parentFile })
|
||||||
@@ -59,7 +63,9 @@ open class KonanLibrariesSpec(val task: KonanArtifactWithLibrariesTask, val proj
|
|||||||
@Internal get() = task.konanTarget
|
@Internal get() = task.konanTarget
|
||||||
|
|
||||||
private val friendsTasks = mutableSetOf<KonanBuildingTask>()
|
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 })
|
addAll(friendsTasks.map { it.artifact })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -48,7 +48,12 @@ internal val Project.simpleOsName
|
|||||||
/** A task with a KonanTarget specified. */
|
/** A task with a KonanTarget specified. */
|
||||||
abstract class KonanTargetableTask: DefaultTask() {
|
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) {
|
internal open fun init(target: KonanTarget) {
|
||||||
this.konanTarget = target
|
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.Console
|
||||||
import org.gradle.api.tasks.Input
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.Internal
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.jetbrains.kotlin.gradle.plugin.konan.*
|
import org.jetbrains.kotlin.gradle.plugin.konan.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.model.KonanModelArtifact
|
import org.jetbrains.kotlin.gradle.plugin.model.KonanModelArtifact
|
||||||
@@ -27,6 +28,7 @@ import java.io.File
|
|||||||
/** Base class for both interop and compiler tasks. */
|
/** Base class for both interop and compiler tasks. */
|
||||||
abstract class KonanBuildingTask: KonanArtifactWithLibrariesTask(), KonanBuildingSpec {
|
abstract class KonanBuildingTask: KonanArtifactWithLibrariesTask(), KonanBuildingSpec {
|
||||||
|
|
||||||
|
@get:Internal
|
||||||
internal abstract val toolRunner: KonanToolRunner
|
internal abstract val toolRunner: KonanToolRunner
|
||||||
internal abstract fun toModelArtifact(): KonanModelArtifact
|
internal abstract fun toModelArtifact(): KonanModelArtifact
|
||||||
|
|
||||||
|
|||||||
+7
-5
@@ -36,8 +36,8 @@ import java.io.File
|
|||||||
*/
|
*/
|
||||||
abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
||||||
|
|
||||||
@Internal override val toolRunner =
|
@get:Internal
|
||||||
KonanCompilerRunner(project, project.konanExtension.jvmArgs)
|
override val toolRunner = KonanCompilerRunner(project, project.konanExtension.jvmArgs)
|
||||||
|
|
||||||
abstract val produce: CompilerOutputKind
|
abstract val produce: CompilerOutputKind
|
||||||
@Internal get
|
@Internal get
|
||||||
@@ -56,13 +56,13 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
|||||||
|
|
||||||
@Internal var enableMultiplatform = false
|
@Internal var enableMultiplatform = false
|
||||||
|
|
||||||
internal val commonSrcFiles_ = mutableSetOf<FileCollection>()
|
private val commonSrcFiles_ = mutableSetOf<FileCollection>()
|
||||||
val commonSrcFiles: Collection<FileCollection>
|
val commonSrcFiles: Collection<FileCollection>
|
||||||
@Internal get() = if (enableMultiplatform) commonSrcFiles_ else emptyList()
|
@Internal get() = if (enableMultiplatform) commonSrcFiles_ else emptyList()
|
||||||
|
|
||||||
// Other compilation parameters -------------------------------------------
|
// Other compilation parameters -------------------------------------------
|
||||||
|
|
||||||
protected val srcFiles_ = mutableSetOf<FileCollection>()
|
private val srcFiles_ = mutableSetOf<FileCollection>()
|
||||||
val srcFiles: Collection<FileCollection>
|
val srcFiles: Collection<FileCollection>
|
||||||
@Internal get() = srcFiles_.takeIf { !it.isEmpty() } ?: listOf(project.konanDefaultSrcFiles)
|
@Internal get() = srcFiles_.takeIf { !it.isEmpty() } ?: listOf(project.konanDefaultSrcFiles)
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ abstract class KonanCompileTask: KonanBuildingTask(), KonanCompileSpec {
|
|||||||
@InputFiles get() = listOf(srcFiles, commonSrcFiles).flatten()
|
@InputFiles get() = listOf(srcFiles, commonSrcFiles).flatten()
|
||||||
|
|
||||||
private val allSourceFiles: List<File>
|
private val allSourceFiles: List<File>
|
||||||
@Internal get() = allSources
|
get() = allSources
|
||||||
.flatMap { it.files }
|
.flatMap { it.files }
|
||||||
.filter { it.name.endsWith(".kt") }
|
.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 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.
|
* 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
|
abstract val enableTwoStageCompilation: Boolean
|
||||||
|
|
||||||
protected fun directoryToKt(dir: Any) = project.fileTree(dir).apply {
|
protected fun directoryToKt(dir: Any) = project.fileTree(dir).apply {
|
||||||
@@ -377,6 +378,7 @@ abstract class KonanCompileNativeBinary: KonanCompileTask() {
|
|||||||
open class KonanCompileProgramTask: KonanCompileNativeBinary() {
|
open class KonanCompileProgramTask: KonanCompileNativeBinary() {
|
||||||
override val produce: CompilerOutputKind get() = CompilerOutputKind.PROGRAM
|
override val produce: CompilerOutputKind get() = CompilerOutputKind.PROGRAM
|
||||||
|
|
||||||
|
@Internal
|
||||||
var runTask: Exec? = null
|
var runTask: Exec? = null
|
||||||
|
|
||||||
inner class RunArgumentProvider(): CommandLineArgumentProvider {
|
inner class RunArgumentProvider(): CommandLineArgumentProvider {
|
||||||
|
|||||||
+4
-3
@@ -22,6 +22,7 @@ import org.gradle.api.file.FileCollection
|
|||||||
import org.gradle.api.tasks.*
|
import org.gradle.api.tasks.*
|
||||||
import org.gradle.util.ConfigureUtil
|
import org.gradle.util.ConfigureUtil
|
||||||
import org.gradle.workers.IsolationMode
|
import org.gradle.workers.IsolationMode
|
||||||
|
import org.gradle.workers.WorkAction
|
||||||
import org.gradle.workers.WorkerExecutor
|
import org.gradle.workers.WorkerExecutor
|
||||||
import org.jetbrains.kotlin.gradle.plugin.konan.*
|
import org.jetbrains.kotlin.gradle.plugin.konan.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.konan.KonanInteropSpec.IncludeDirectoriesSpec
|
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.
|
* 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 =
|
@get:Internal
|
||||||
KonanInteropRunner(project, project.konanExtension.jvmArgs)
|
override val toolRunner: KonanToolRunner = KonanInteropRunner(project, project.konanExtension.jvmArgs)
|
||||||
|
|
||||||
override fun init(config: KonanBuildingConfig<*>, destinationDir: File, artifactName: String, target: KonanTarget) {
|
override fun init(config: KonanBuildingConfig<*>, destinationDir: File, artifactName: String, target: KonanTarget) {
|
||||||
super.init(config, destinationDir, artifactName, target)
|
super.init(config, destinationDir, artifactName, target)
|
||||||
|
|||||||
Reference in New Issue
Block a user