Skip to content

Instantly share code, notes, and snippets.

@keithrbennett
Created June 13, 2013 02:56
Show Gist options
  • Save keithrbennett/5770915 to your computer and use it in GitHub Desktop.
Save keithrbennett/5770915 to your computer and use it in GitHub Desktop.
Shows a strategy for creating both MRI and JRuby versions of a gem.
# Builds the gem for the current rvm ruby/platform.
# Run this once for MRI and once for JRuby, as in:
#
# rvm 1.9
# ./build_gem.sh
# rvm jruby
# ./build_gem.sh
GEM_NAME=my_gem
GEM_SPEC=${GEM_NAME}.gemspec
RUBY_VERSION=`rvm current`
GEMFILE_LOCK_VERSION_SAVE_NAME=Gemfile.lock.${RUBY_VERSION}
echo Building gem $GEM_NAME from $GEM_SPEC for Ruby version $RUBY_VERSION.
echo The Gemfile.lock for this version will be copied to $GEMFILE_LOCK_VERSION_SAVE_NAME.
mv Gemfile.lock Gemfile.sav 2> /dev/null
echo Running bundle install...
bundle install
cp Gemfile.lock $GEMFILE_LOCK_VERSION_SAVE_NAME
echo Building gem from $GEM_SPEC...
gem build $GEM_SPEC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment