Created
April 9, 2012 21:58
-
-
Save myabc/2346845 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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