cbt icon indicating copy to clipboard operation
cbt copied to clipboard

java.io.Console does not work via nailgun

Open cvogt opened this issue 7 years ago • 5 comments

java.io.Console is null when running via nailgun, but it is what is usually used to allow interactive input, as we need for gpg, repl, clean, etc. Currently all of those require cbt direct in order to work.

I see several possible solutions. Either we use something other than Console, which works with nailgun. This probably requires writing an abstraction over Console and whatever the nailgun equivalent is. CBT, plugins and potentially even project code would use the abstraction instead of the jdk built-in concepts. This obviously requires the application to be aware of this and run against the wrapper instead of directly against the jdk. This may be fine for CBT+plugins, but likely infeasible for applications compiled with CBT or simply used by CBT or CBT projects, such as the Scala repl.

Alternatively we could investigate if things like https://github.com/ninjudd/drip solve this better.

Or we could investigate if we could highjack/monkey-patch JDK built-ins by wrapper proxy's that redirect to Nailgun equivalents if necessary and otherwise use the actial JDK built-ins.

cvogt avatar Sep 28 '16 11:09 cvogt

Currently the workaround is calling cbt tasks that require this via the direct meta task, e.g. cbt direct publishSigned, so that java.io.Console is available.

cvogt avatar Sep 28 '16 11:09 cvogt

We may be able to use System.in instead of console

cvogt avatar Oct 31 '16 05:10 cvogt

we use in, out and err provided by NGContext for I/O. Also see https://github.com/cvogt/cbt/issues/197

cvogt avatar Mar 03 '17 12:03 cvogt

This may help: http://illegalargumentexception.blogspot.com/2010/09/java-systemconsole-ides-and-testing.html

cvogt avatar Mar 21 '17 05:03 cvogt

java.io.Console is null also when you pipe output of cbt like cbt run | less without nailgun. So, you run into this problem each time you have several mains and run cbt run piped.

buzden avatar Feb 24 '18 16:02 buzden