Project provides KtsExec
Gradle task that runs Kotlin scripts.
You can add no-op plugin, that automatically adds KtsExec
task type
and does nothing more:
plugins {
id("by.egorr.gradle.ktsexec-plugin") version "1.1.0"
}
repositories {
// Required for KtsExec task dependencies
jcenter()
}
Alternatively, you can add following block to your root build.gradle.kts
to get KtsExec
task type:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath("by.egorr.gradle:ktsexec-task:1.1.0")
}
}
repositories {
// Required for KtsExec task dependencies
jcenter()
}
Start adding tasks, similar to JavaExec
:
tasks.create("runSomeScript", by.egorr.gradle.ktsexec.KtsExec::class.java) {
group = "Scripts"
script.set(file("scripts/awesome_script.kts"))
}
Check also sample/
directory that provides sample Gradle project.
Current version supports only simple Kotlin scripts, without any advanced use-cases (like external dependencies).
- https://github.com/NikkyAI/MinimalScriptingExample - implementation inspiration repo
- Kotlin script KEEP
- Official script examples