commonMain.co.touchlab.skie.plugin.util.BaseSkieTask.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-plugin-impl-jvm Show documentation
Show all versions of gradle-plugin-impl-jvm Show documentation
Internal implementation for SKIE Gradle plugin.
package co.touchlab.skie.plugin.util
import co.touchlab.skie.plugin.SkieTarget
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.TaskProvider
fun SkieTarget.skieTargetBasedTaskName(baseName: String): String {
val linkTaskNameWithoutPrefix = when (this) {
is SkieTarget.Binary -> task.name.removePrefix("link")
is SkieTarget.Artifact -> task.name.removePrefix("assemble")
}
return lowerCamelCaseName(
"skie",
baseName,
linkTaskNameWithoutPrefix,
)
}
inline fun SkieTarget.registerSkieTargetBasedTask(
baseName: String,
crossinline configurationAction: T.() -> Unit,
): TaskProvider {
val taskName = skieTargetBasedTaskName(baseName)
return project.registerSkieTask(taskName, prefix = null, configurationAction = configurationAction)
}
inline fun Project.registerSkieTask(
baseName: String,
prefix: String? = "skie",
crossinline configurationAction: T.() -> Unit,
): TaskProvider {
val taskName = lowerCamelCaseName(prefix, baseName)
return tasks.register(taskName, T::class.java) {
this.group = "skie"
this.configurationAction()
}
}