Created
October 27, 2009 05:06
-
-
Save woodie/219335 to your computer and use it in GitHub Desktop.
bundle and jar up from within ruby
This file contains 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
require 'rubygems' | |
require 'fileutils' | |
require 'zip/zip' | |
require 'zip/zipfilesystem' | |
require 'rubygems/command_manager' | |
# ... | |
def gem_bundler(args) | |
Gem.platforms = [Gem::Platform::RUBY, | |
Gem::Platform.new('universal-java')] | |
Gem.configuration = Gem::ConfigFile.new(args.unshift('bundle')) | |
puts "=> Bundling gems" | |
begin | |
Gem::CommandManager.instance.run(Gem.configuration.args) | |
rescue Gem::SystemExitException => e | |
exit e.exit_code unless e.exit_code == 0 | |
end | |
if !args.include?('--update') and File.exists?(app.gems_jar) and | |
File.stat(app.gems_jar).mtime > File.stat(app.gemfile).mtime | |
return | |
end | |
gem_files = Dir["#{app.gems_dir}/**/**"] | |
FileUtils.rm app.gems_jar, :force => true # blow away the old jar | |
puts "=> Installing gems" | |
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) | |
end | |
end | |
end | |
# ... |
This file contains 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
# Critical default settings: | |
disable_system_gems | |
disable_rubygems | |
bundle_path ".gems/bundler_gems" | |
# List gems to bundle here: | |
#gem "rack", "1.0.0" | |
gem "dm-appengine" | |
gem "sinatra" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment