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

commonMain.co.touchlab.skie.plugin.util.TaskDoOptimized.kt Maven / Gradle / Ivy

There is a newer version: 0.9.0-RC.5
Show newest version
@file:Suppress("ObjectLiteralToLambda")

package co.touchlab.skie.plugin.util

import org.gradle.api.Action
import org.gradle.api.Task
import org.gradle.api.tasks.TaskProvider

// We need to use an anonymous class instead of lambda to keep execution optimizations.
// https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implementation_unknown
inline fun Task.doFirstOptimized(crossinline action: () -> Unit): Task =
    doFirst(
        object : Action {
            override fun execute(task: Task) {
                action()
            }
        },
    )

inline fun TaskProvider.configureDoFirstOptimized(crossinline action: () -> Unit) =
    configure {
        doFirstOptimized(action)
    }

inline fun Task.doLastOptimized(crossinline action: () -> Unit): Task =
    doLast(
        object : Action {
            override fun execute(task: Task) {
                action()
            }
        },
    )

inline fun TaskProvider.configureDoLastOptimized(crossinline action: () -> Unit) =
    configure {
        doLastOptimized(action)
    }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy