Gradle Task prompt for password, how?

I have an Exec Task, that was supposed to prompt for password. But gradle task doesn’t seem to propagate that the task instead hung for a bit(I take it the underline process is waiting for input).

How to propagate/pipe this prompt?
Currently I work around by launching a SwingBuilder dialog to gget the password then
commandLine “echo”, pass, “|” …myscript

though I suppose there should have been a better way?

Did you look at System.console().readLine() and System.console.readPassword()?

Those won’t work with the Gradle daemon. You can see some info about this type of request in Gradle did some work recently to allow for inputs for the --scan command line tool to accept license, but I do not think there is a public API for this right now.

1 Like

Yeah forgot to mention that I did. But like mkobit said, it won’t work by default with new gradle deamon on.

There is a workaround (to handle null console when using daemon), described in the issue too

At the moment you don’t have many alternatives to solve your question :smile:: console or UI using SwingBuilder. Both variants you can handle in your task.