Skip to content

Instantly share code, notes, and snippets.

@myabc myabc/Rakefile
Created Apr 9, 2012

Embed
What would you like to do?
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.