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

io.appmetrica.gradle.aarcheck.tasks.TaskManager.kt Maven / Gradle / Ivy

The newest version!
package io.appmetrica.gradle.aarcheck.tasks

import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.TaskProvider
import kotlin.reflect.KClass

class TaskManager(private val project: Project) {
    companion object {
        const val GROUP_NAME = "aar check"
    }

    fun registerIfNotExists(name: String, createAction: TaskProvider.() -> Unit = {}): TaskProvider {
        return if (name in project.tasks.names) {
            project.tasks.named(name)
        } else {
            register(name).also(createAction)
        }
    }

    inline fun  register(name: String, noinline configuration: T.() -> Unit = {}): TaskProvider =
        register(name, T::class, configuration)

    fun  register(name: String, type: KClass, configuration: T.() -> Unit = {}): TaskProvider =
        project.tasks.register(name, type.java) {
            group = GROUP_NAME
            configuration()
        }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy