-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathext_helper_java.rb
33 lines (28 loc) · 978 Bytes
/
ext_helper_java.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#
# a version of setup_extension for Java
#
def setup_extension_java(extension_name, gem_spec = nil)
ext_name = "#{extension_name}.jar"
directory 'lib'
unless File.directory?("ext/#{extension_name}")
desc 'Compile Extension for current Ruby (= compile:jruby)'
task :compile => [ 'compile:jruby' ] if JRUBY
namespace :compile do
desc "Compile Java Extension for JRuby"
#task :jruby => ["lib/#{ext_name}"]
task :jruby do
begin
# gem 'buildr', '1.3.1.1'
# require 'buildr'
# FIXME: this is throwing rspec activation errors
sh %{jruby -S buildr package}
buildr_output = extension_name.gsub(/_(ext)$/, '-\1-java-1.0.jar')
cp "ext-java/target/#{buildr_output}", "lib/#{ext_name}"
rescue LoadError
puts "#{spec.name} requires the buildr gem to compile the Java extension"
end
end
end
file "lib/#{ext_name}" => 'compile:jruby'
end
end