Skip to content

Commit ad6555c

Browse files
committed
Do not hardcode the JRuby path
1 parent fe434f3 commit ad6555c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Rakefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ edge_gemspec = Gem::Specification.load File.join(__dir__, 'concurrent-ruby-edge.
1818

1919
require 'rake/javaextensiontask'
2020

21-
JRUBY_JAR_PATH = '/usr/local/opt/rbenv/versions/jruby-9.1.17.0/lib/jruby.jar'
22-
2321
class ConcurrentRubyJavaExtensionTask < Rake::JavaExtensionTask
2422
def java_classpath_arg(*args)
2523
jruby_cpath = nil
@@ -42,10 +40,15 @@ class ConcurrentRubyJavaExtensionTask < Rake::JavaExtensionTask
4240
end
4341

4442
unless jruby_cpath
45-
jruby_cpath = JRUBY_JAR_PATH
46-
raise "#{jruby_cpath} does not exist" unless File.exist? jruby_cpath
43+
jruby_home = ENV['JRUBY_HOME']
44+
if jruby_home
45+
candidate = File.join(jruby_home, 'lib', 'jruby.jar')
46+
jruby_cpath = candidate if File.exist? candidate
47+
end
4748
end
4849

50+
raise "jruby.jar path not found" unless jruby_cpath
51+
4952
jruby_cpath += File::PATH_SEPARATOR + args.join(File::PATH_SEPARATOR) unless args.empty?
5053
jruby_cpath ? "-cp \"#{jruby_cpath}\"" : ""
5154
end

0 commit comments

Comments
 (0)