1

I want to modify my build.gradle.kts by implementing some tasks. Specially, I want to obtain the output of the first task in my second task, where the first task runs a shell command. There are some basic examples here and here, which are implemented in groovy dsl. Now, I need this functionality in kotlin dsl.

A working example is:

task<Exec>("avdIsRunning") {
        commandLine("adb", "devices")
        standardOutput = ByteArrayOutputStream()
    
}
task("task2") {
    dependsOn("avdIsRunning")
      doLast {
        val standardOutput = (tasks.getByName("avdIsRunning") as Exec).standardOutput.toString()
        println("Foo's output: $standardOutput")
      }
  }

What I want is, to call a extension method avdIsRunning.output() that provides the standradOutput of avdIsRunning-task, compare to the examples I linked above.

Hölderlin
  • 424
  • 1
  • 3
  • 16

0 Answers0