Running a gradle task using gradle-tooling-api where the task itself launches an interactive shell of another application

I have created a task called runShell which can be used to run interactive shell ( such as groovysh or pig) by following the accepted answer in It works fine and the shell waits for input and gives proper output when I run it using gradle runShell on command line.

I have another application which uses gradle-tooling-api to run this task. When I try to run this task from my application, I cannot see the output from the task and also it doesn’t wait for the input. It just exits with success code.

I want to run the runShell task using the gradle tooling api and redirect input/output to the interactive shell which is being run by this task.

I’m setting the standardInput, standardOutput and standardError in the following way:


Any help would be really appreciated.