Run a Gradle task from plugin

Is there a way of running a Gradle task from a plugin using Open API or smth else from IntelliJ SDK and get the output of that task? There's this `Run Anything` action, which can run a command but doesn't seem to be capturing the output, and the IDE itself must have some sort of mechanism to launch a Gradle task (since there is a Gradle menu which displays all tasks from your build files and a click on the task launches it), but I don't know how if I can use this from a custom plugin and if I can then is there a way to capture the output.

I'd use the very simple `Runtime.exec("gradle customtask")` (a similar question suggests that this is apparently possible for Maven, as per the last post in the topic:, but it results in an exception (`Caused by: Cannot run program "gradle": error=2, No such file or directory`), and I'm not sure why (is this because the IDE instance runs in a sandbox? Terribly sorry, I'm somewhat new to plugin development)


Please sign in to leave a comment.