All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.co.touchlab.skie.plugin.directory.SkieDirectoriesManager.kt Maven / Gradle / Ivy

There is a newer version: 0.9.0-RC.5
Show newest version
package co.touchlab.skie.plugin.directory

import co.touchlab.skie.plugin.SkieTarget
import co.touchlab.skie.plugin.util.registerSkieTargetBasedTask
import co.touchlab.skie.plugin.util.skieTargetBasedTaskName
import co.touchlab.skie.util.directory.SkieDirectories
import org.gradle.api.DefaultTask
import org.gradle.api.Task
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.TaskProvider
import javax.inject.Inject

object SkieDirectoriesManager {

    const val baseTaskName: String = "createSkieDirectories"

    fun configureCreateSkieBuildDirectoryTask(target: SkieTarget) {
        target.registerSkieTargetBasedTask(baseTaskName) {
            skieDirectories.set(target.skieDirectories)
        }
    }

    abstract class SkieCreateSkieDirectoriesTask @Inject constructor(objects: ObjectFactory) : DefaultTask() {

        @get:Internal
        val skieDirectories: Property = objects.property(SkieDirectories::class.java)

        init {
            outputs.dirs(skieDirectories.map { it.directories })
        }

        @TaskAction
        fun runTask() {
            skieDirectories.get().run {
                createDirectories()
                resetTemporaryDirectories()
            }
        }
    }
}

val SkieTarget.createSkieBuildDirectoryTask: TaskProvider
    get() = project.tasks.named(skieTargetBasedTaskName(SkieDirectoriesManager.baseTaskName))




© 2015 - 2024 Weber Informatics LLC | Privacy Policy