/
Rakefile
30 lines (24 loc) · 1.04 KB
/
Rakefile
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
task :java_compile do
# Pick the right class path, depending if we're using an rvm installed JRuby
jruby_cpath = ENV['MY_RUBY_HOME'] || ENV['JRUBY_HOME']
raise 'MY_RUBY_HOME or JRUBY_HOME are not set' unless jruby_cpath
puts 'Doing a simple compilation'
sh %(javac -source 1.6 -target 1.6 -cp #{jruby_cpath}/lib/jruby.jar java/**/*.java)
mkdir_p '../lib/jrubytesting'
sh %(jar cf ../lib/jrubytesting/test_jruby_library.jar -C java jrubytesting/TestJrubyLibraryService.class)
puts
end
task :c_compile do
require 'rubygems/ext'
gem_dir = File.expand_path(File.dirname(__FILE__) + '../../')
extension_dir = File.join(gem_dir, File.dirname('ext/jrubytesting/extconf.rb'))
dest_path = File.join(gem_dir, 'lib/jrubytesting')
Dir.chdir(extension_dir) do
results = Gem::Ext::ExtConfBuilder.build('extconf.rb', gem_dir, dest_path, [])
say results.join("\n") if Gem.configuration.really_verbose
end
end
def is_jruby?
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
end
task :default => is_jruby? ? :java_compile : :c_compile