diff options
author | Prashant Vithani <prashantvithani@gmail.com> | 2019-01-02 10:14:00 +0530 |
---|---|---|
committer | Prashant Vithani <prashantvithani@gmail.com> | 2019-01-02 10:14:00 +0530 |
commit | 00c17e017db08d46aa6cc15cff7a62c83c1ee7f0 (patch) | |
tree | c0cd3395d686169e762fcdcb3d5aeab7371a91bc /lib/rake | |
parent | 498ba0d45372f882957cb0c72446c88ecca60a2a (diff) | |
download | rake-compiler-00c17e017db08d46aa6cc15cff7a62c83c1ee7f0.tar.gz |
Fix cross-platform compilation for Java extensions
Using `libdir` provided by `RbConfig` to compile java extension from MRI
breaks as it can't find `jruby.jar` under `lib` directory. Added a check
on file existence if the path is taken from RbConfig and if it doesn't
exist, check for the path which is set in environment JRUBY_HOME to find
correct `jruby.jar`.
Raise the error to abort compilation if `jruby.jar` is not found.
Diffstat (limited to 'lib/rake')
-rw-r--r-- | lib/rake/javaextensiontask.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/rake/javaextensiontask.rb b/lib/rake/javaextensiontask.rb index 15cc2f7..916de53 100644 --- a/lib/rake/javaextensiontask.rb +++ b/lib/rake/javaextensiontask.rb @@ -212,13 +212,26 @@ execute the Rake compilation task using the JRuby interpreter. rescue => e end end + unless jruby_cpath libdir = RbConfig::CONFIG['libdir'] if libdir.start_with? "classpath:" raise 'Cannot build with jruby-complete' end - jruby_cpath = File.join(libdir, "jruby.jar") + 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 + 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 |