I am trying to run the code block below, after reading multiple posts on the topic and the Gradle manual. I run the below and get the following error: execCommand == null!
Any ideas on what I am doing wrong with the below code block?
open class BuildDataClassFromAvro : org.gradle.api.tasks.Exec() {
@TaskAction
fun build() {
println("Building data classes.....")
commandLine("date")
}
}
tasks.register<BuildDataClassFromAvro>("buildFromAvro") {
description = "Do stuff"
}
Exec
task is for running a cmd-line process, so you don't need to actually create a Kotlin class that subclasses it: instead you create a Gradle task of typeExec
and define thecommandLine
in there (see docs.gradle.org/current/dsl/org.gradle.api.tasks.Exec.html). Are you trying to run a cmd-line process? Or are you trying to write a task that will run some custom Kotlin code? – Pedaiah