Run Kotlin script in Android Gradle task
I have a script that generates a Kotlin file from an external JSON file in my project (using Kotlin Poet), under app/src/.../scripts/Script.Kt with a main() function.
I want Gradle to automatically run this script during the build phase. What is the appropriate way to do this?
I've tried declaring a JavaExec task like this
task gen(type: JavaExec) {
// sourceSets.main.runtimeClasspath does not work
classpath += files("${buildDir}/tmp/kotlin-classes/debug")
main = '.ScriptKt'
}...