System.console() returns null when used in conjunction with org.gradle.java.home property

I’m trying to use the System.console() from within my gradle script. All seems to be working fine EXCEPT when I am using the org.gradle.java.home property. If I have that set to switch to a different jvm then I get null as a return from System.console().

The reason I need to switch jvms is because I’m on a 64-bit machine. One of my tasks interacts with the Starteam ant tasks, which basically farms out the work as a native library to the Starteam client. The Starteam client libraries are only 32-bit, so when I need to run those specific tasks I use the org.gradle.java.home property to switch to a 32-bit jdk. When I do this System.console() also stops working.

I even tried ant’s input task, which does still seem to work, except for the SecureInputHandler (I am reading a username & password). When I use ant’s input task the password still echos to the screen.

Is there a workaround for this?

Are you using the Gradle daemon? If not, can you enable it and check if it makes a difference?

Doesn’t seem to make a difference. I still get “Cannot invoke method readLine() on null object” when trying to do System.console().readLine() or System.console().readPassword().

If I remove the line org.gradle.java.home from my gradle.properties the System.console() works (but then my starteam ant tasks don’t because of the fact the default runtime jvm on my machine (& on our CI servers) is 64-bit.

Might be a bug then. I’ve raised GRADLE-2386.