lib/appengine-tools/gem_bundler.rb in appengine-tools-0.0.7 vs lib/appengine-tools/gem_bundler.rb in appengine-tools-0.0.8.pre
- old
+ new
@@ -20,19 +20,15 @@
require 'zip/zip'
require 'zip/zipfilesystem'
require 'rubygems/command_manager'
require 'appengine-tools/bundler'
-# Support Ruby 1.6, without active_support/extensions/facets
-class Symbol
- def to_proc
- Proc.new { |*args| args.shift.__send__(self, *args) }
- end unless :to_proc.respond_to?(:to_proc)
-end
-
module AppEngine
module Admin
+ TARGET_VERSION = '1.8'
+ TARGET_ENGINE = 'jruby'
+ GEM_PLATFORM = Gem::Platform.new("universal-java-1.6")
class GemBundler
def initialize(root)
@root = root
@@ -58,49 +54,58 @@
return true
end
def gem_bundle(args)
return unless args.include?('--update') || gems_out_of_date
- Gem.platforms = [Gem::Platform::RUBY,
- Gem::Platform.new('universal-java')]
+ Gem.platforms = [Gem::Platform::RUBY, GEM_PLATFORM]
Gem.configuration = Gem::ConfigFile.new(args.unshift('bundle'))
+ ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : nil
+ # Override RUBY_ENGINE (we bundle from MRI for JRuby)
+ Object.const_set('RUBY_ENGINE', TARGET_ENGINE)
puts "=> Bundling gems"
begin
Dir.chdir(@root) do
Gem::CommandManager.instance.run(Gem.configuration.args)
end
rescue Gem::SystemExitException => e
exit e.exit_code unless e.exit_code == 0
end
+ # Restore RUBY_ENGINE (limit the scope of this hack)
+ Object.const_set('RUBY_ENGINE', ruby_engine) unless ruby_engine.nil?
bundler_dir = "#{app.gems_dir}/bundler_gems"
+ target_pair = "#{TARGET_ENGINE}/#{TARGET_VERSION}"
+ gem_patch = "require 'bundler_gems/#{target_pair}/environment'"
+ File.open("#{bundler_dir}/environment.rb",'w') {|f| f << gem_patch }
FileUtils.rm app.gems_jar, :force => true # blow away the old jar
puts "=> Packaging gems"
- gem_files = Dir["#{bundler_dir}/gems/**/**"] +
- Dir["#{bundler_dir}/dirs/**/**"] +
+ gem_files = Dir["#{bundler_dir}/#{target_pair}/dirs/**/**"] +
+ Dir["#{bundler_dir}/#{target_pair}/gems/**/**"] +
+ Dir["#{bundler_dir}/#{target_pair}/environment.rb"] +
Dir["#{bundler_dir}/environment.rb"]
Zip::ZipFile.open(app.gems_jar, 'w') do |jar|
gem_files.reject {|f| f == app.gems_jar}.each do |file|
- jar.add(file.sub("#{app.gems_dir}/",''), file)
+ if file[-4..-1].eql? '.jar'
+ puts "Installing #{File.basename(file)}"
+ FileUtils.cp file, app.webinf_lib
+ else
+ jar.add(file.sub("#{app.gems_dir}/",''), file)
+ end
end
end
end
def verify_gemfile
return if File.exists?(app.gemfile)
puts "=> Generating gemfile"
-
- # TODO: Maybe we should include the latest
- # versions from updatecheck here?
+ # TODO: include the latest versions from updatecheck here?
stock_gemfile = <<EOF
# Critical default settings:
disable_system_gems
disable_rubygems
bundle_path ".gems/bundler_gems"
# List gems to bundle here:
gem "appengine-rack"
-#gem "dm-appengine"
-#gem "sinatra"
EOF
File.open(app.gemfile,'w') {|f| f.write(stock_gemfile) }
end
end
end