Class: Buildr::Shell::JIRB

Inherits:
Base show all
Includes:
JRebel
Defined in:
lib/buildr/core/shell.rb

Constant Summary collapse

JRUBY_VERSION =
'1.6.2'

Instance Attribute Summary

Attributes inherited from Base

#project

Instance Method Summary collapse

Methods included from JRebel

#jrebel_args, #jrebel_home, #jrebel_props, #rebel_jar

Methods inherited from Base

#initialize, specify, to_sym

Constructor Details

This class inherits a constructor from Buildr::Shell::Base

Instance Method Details

#launch(task) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/buildr/core/shell.rb', line 55

def launch(task)
  if jruby_home     # if JRuby is installed, use it
    cp = project.compile.dependencies +
      [project.path_to(:target, :classes)] +
      Dir.glob("#{jruby_home}#{File::SEPARATOR}lib#{File::SEPARATOR}*.jar") +
      task.classpath

    props = {
      'jruby.home' => jruby_home,
      'jruby.lib' => "#{jruby_home}#{File::SEPARATOR}lib"
    }
    props.merge! jrebel_props(project)
    props.merge! task.properties

    unless Util.win_os?
      uname = `uname -m`
      cpu = if uname =~ /i[34567]86/
        'i386'
      elsif uname == 'i86pc'
        'x86'
      elsif uname =~ /amd64|x86_64/
        'amd64'
      end

      os = `uname -s | tr '[A-Z]' '[a-z]'`
      path = if os == 'darwin'
        'darwin'
      else
        "#{os}-#{cpu}"
      end

      props['jna.boot.library.path'] = "#{jruby_home}/lib/native/#{path}"
    end

    props['jruby.script'] = if Util.win_os? then 'jruby.bat' else 'jruby' end
    props['jruby.shell'] = if Util.win_os? then 'cmd.exe' else '/bin/sh' end

    args = [
      "-Xbootclasspath/a:#{Dir.glob("#{jruby_home}#{File::SEPARATOR}lib#{File::SEPARATOR}jruby*.jar").join File::PATH_SEPARATOR}"
    ] + jrebel_args + task.java_args

    Java::Commands.java 'org.jruby.Main', "#{jruby_home}#{File::SEPARATOR}bin#{File::SEPARATOR}jirb", {
      :properties => props,
      :classpath => cp,
      :java_args => args
    }
  else
    cp = project.compile.dependencies + [ jruby_artifact, project.path_to(:target, :classes) ] +
         task.classpath
    props = jrebel_props(project).merge(task.properties)
    args = jrebel_args + task.java_args

    Java::Commands.java 'org.jruby.Main', '--command', 'irb', {
      :properties => props,
      :classpath => cp,
      :java_args => args
    }
  end
end