diff options
author | Prashant Vithani <prashantvithani@gmail.com> | 2019-01-03 14:21:08 +0530 |
---|---|---|
committer | Prashant Vithani <prashantvithani@gmail.com> | 2019-01-03 14:21:08 +0530 |
commit | e69e7c0d6a02ed19a7edfa185eb7d0de9a69fbd2 (patch) | |
tree | a8d475d0df1933be5a2c573445d8c55312cf461e /lib/rake | |
parent | 00c17e017db08d46aa6cc15cff7a62c83c1ee7f0 (diff) | |
download | rake-compiler-e69e7c0d6a02ed19a7edfa185eb7d0de9a69fbd2.tar.gz |
Raise error with proper message
Add comments explaining each condition.
Diffstat (limited to 'lib/rake')
-rw-r--r-- | lib/rake/javaextensiontask.rb | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/rake/javaextensiontask.rb b/lib/rake/javaextensiontask.rb index 916de53..592da3a 100644 --- a/lib/rake/javaextensiontask.rb +++ b/lib/rake/javaextensiontask.rb @@ -213,25 +213,33 @@ execute the Rake compilation task using the JRuby interpreter. end end + # jruby_cpath might not be present from Java-9 onwards as it removes + # sun.boot.class.path. Check if JRUBY_HOME is set as env variable and try + # to find jruby.jar under JRUBY_HOME + unless jruby_cpath + jruby_home = ENV['JRUBY_HOME'] + if jruby_home + candidate = File.join(jruby_home, 'lib', 'jruby.jar') + jruby_cpath = candidate if File.exist? candidate + end + end + + # JRUBY_HOME is not necessarily set in JRuby-9.x + # Find the libdir from RbConfig::CONFIG and find jruby.jar under the + # found lib path unless jruby_cpath libdir = RbConfig::CONFIG['libdir'] - if libdir.start_with? "classpath:" - raise 'Cannot build with jruby-complete' + if libdir.start_with? "uri:classloader:" + raise 'Cannot build with jruby-complete from Java 9 onwards' end candidate = File.join(libdir, "jruby.jar") jruby_cpath = candidate if File.exist? candidate end unless jruby_cpath - jruby_home = ENV['JRUBY_HOME'] - if jruby_home - candidate = File.join(jruby_home, 'lib', 'jruby.jar') - jruby_cpath = candidate if File.exist? candidate - end + raise "Could not find jruby.jar. Please set JRUBY_HOME or Use jruby in rvm" end - raise "jruby.jar path not found" unless jruby_cpath - jruby_cpath += File::PATH_SEPARATOR + args.join(File::PATH_SEPARATOR) unless args.empty? jruby_cpath ? "-cp \"#{jruby_cpath}\"" : "" end |