You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by do...@apache.org on 2013/10/09 20:43:50 UTC
svn commit: r1530758 - in /buildr/trunk/lib: buildr.rb buildr/core/console.rb
Author: donaldp
Date: Wed Oct 9 18:43:50 2013
New Revision: 1530758
URL: http://svn.apache.org/r1530758
Log:
Readd in jline support for jruby on on windows. It will attempt to use the jline associated with the the jruby 1.7.* code path, and then the jruby 1.6.* code path. However this may still cause issues when other libraries have also loaded jline (i.e. Scala) in which case the code will revert to using a black and white console
Modified:
buildr/trunk/lib/buildr.rb
buildr/trunk/lib/buildr/core/console.rb
Modified: buildr/trunk/lib/buildr.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr.rb?rev=1530758&r1=1530757&r2=1530758&view=diff
==============================================================================
--- buildr/trunk/lib/buildr.rb (original)
+++ buildr/trunk/lib/buildr.rb Wed Oct 9 18:43:50 2013
@@ -105,3 +105,6 @@ class Object #:nodoc:
end
end
+# Need to set this again as jruby was not correctly
+# initialized, the first time it was called
+Buildr::Console.use_color = $stdout.isatty
Modified: buildr/trunk/lib/buildr/core/console.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/console.rb?rev=1530758&r1=1530757&r2=1530758&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/console.rb (original)
+++ buildr/trunk/lib/buildr/core/console.rb Wed Oct 9 18:43:50 2013
@@ -23,12 +23,51 @@ module Buildr #nodoc
end
def use_color=(use_color)
- if Buildr::Util.win_os? && use_color
- begin
- require 'Win32/Console/ANSI'
- rescue LoadError
- return
+ begin
+ if Buildr::Util.win_os? && use_color
+ if Buildr::Util.java_platform?
+ require 'java'
+ require 'readline'
+ begin
+ # Attempt jruby 1.7.0->1.7.4 code path
+ java_import 'jline.console.ConsoleReader'
+ input = $stdin.to_inputstream
+ output = $stdout.to_outputstream
+ @java_console = Java::JlineConsole::ConsoleReader.new(input, output)
+ @java_console.set_history_enabled(false)
+ @java_console.set_bell_enabled(true)
+ @java_console.set_pagination_enabled(false)
+ @java_terminal = @java_console.getTerminal
+ rescue Error
+ # Attempt jruby 1.6.* code path
+
+ java_import java.io.OutputStreamWriter
+ java_import java.nio.channels.Channels
+ java_import jline.ConsoleReader
+ java_import jline.Terminal
+
+ @java_input = Channels.newInputStream($stdin.to_channel)
+ @java_output = OutputStreamWriter.new(Channels.newOutputStream($stdout.to_channel))
+ @java_terminal = Terminal.getTerminal
+ @java_console = ConsoleReader.new(@java_input, @java_output)
+ @java_console.setUseHistory(false)
+ @java_console.setBellEnabled(true)
+ @java_console.setUsePagination(false)
+ end
+ else
+ require 'Win32/Console/ANSI'
+ end
end
+ rescue Java::JavaLang::IncompatibleClassChangeError
+ # Unfortunately we have multiple incompatible jline libraries
+ # in the classpath. This is probably because we are using jruby
+ # 1.7.5 with a library like scala and both use incompatible jline
+ # implementations
+ return
+ rescue NameError
+ return
+ rescue LoadError
+ return
end
@use_color = use_color
end
@@ -45,7 +84,15 @@ module Buildr #nodoc
def console_dimensions
begin
if Buildr::Util.win_os?
- Win32::Console.new(Win32::Console::STD_OUTPUT_HANDLE).MaxWindow
+ if Buildr::Util.java_platform?
+ if JRUBY_VERSION =~ /^1.7/
+ [@java_terminal.get_width, @java_terminal.get_height]
+ else
+ [@java_terminal.getTerminalWidth, @java_terminal.getTerminalHeight]
+ end
+ else
+ Win32::Console.new(Win32::Console::STD_OUTPUT_HANDLE).MaxWindow
+ end
elsif $stdout.isatty
if /solaris/ =~ RUBY_PLATFORM and
`stty` =~ /\brows = (\d+).*\bcolumns = (\d+)/