Created
February 7, 2012 00:17
-
-
Save rsutphin/1756109 to your computer and use it in GitHub Desktop.
Example for a question about jar-packaged gems in JRuby
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
aker-gems.jar | |
gem_home |
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
#!/bin/bash -e | |
## | |
# Demonstrates a difference in gem handling for jar-packaged gems in | |
# JRuby. If the the jar is `require`d, the gems are available. If the | |
# jar is placed on the classpath manually, the gems are not | |
# available. The text of [1] suggests both should work. | |
# | |
# [1]: http://blog.nicksieger.com/articles/2009/01/10/jruby-1-1-6-gems-in-a-jar | |
JRUBY_VERSION=1.6.6 | |
if [ -z $JRUBY_COMPLETE ]; then | |
JRUBY_COMPLETE="$HOME/.m2/repository/org/jruby/jruby-complete/${JRUBY_VERSION}/jruby-complete-${JRUBY_VERSION}.jar" | |
fi | |
echo "Using jruby-complete jar '${JRUBY_COMPLETE}'" | |
echo "Creating gemjar" | |
mkdir -p gem_home | |
GEM_HOME=`pwd`/gem_home GEM_PATH='' java -jar ${JRUBY_COMPLETE} -S gem install aker -v 3.0.3 | |
cd gem_home | |
jar cf ../aker-gems.jar . | |
cd .. | |
echo | |
echo "gem list with gemjar required:" | |
GEM_HOME='' GEM_PATH='' java -jar ${JRUBY_COMPLETE} -raker-gems.jar -S gem list | |
echo | |
echo "gem list with gemjar on classpath:" | |
GEM_HOME='' GEM_PATH='' java -cp aker-gems.jar -jar ${JRUBY_COMPLETE} -S gem list |
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
$ ./gemjar-test.sh | |
Using jruby-complete jar '/Users/rsutphin/.m2/repository/org/jruby/jruby-complete/1.6.6/jruby-complete-1.6.6.jar' | |
Creating gemjar | |
Fetching: rubytree-0.7.0.gem (100%) | |
======================================================================== | |
Thank you for installing rubytree. | |
Please note that a few APIs have been deprecated since Version 0.6.1. | |
Specifically, the 'Tree::TreeNode#depth' method is now deprecated, and | |
a new nodeDepth() method has been introduced. | |
Details of the API changes are documented in the API-CHANGES file. | |
======================================================================== | |
Fetching: i18n-0.6.0.gem (100%) | |
Fetching: multi_json-1.0.4.gem (100%) | |
Fetching: activesupport-3.2.1.gem (100%) | |
Fetching: net-ldap-0.1.1.gem (100%) | |
Fetching: castanet-1.0.1.gem (100%) | |
Fetching: rack-1.4.1.gem (100%) | |
Fetching: warden-1.1.0.gem (100%) | |
Fetching: aker-3.0.3.gem (100%) | |
Successfully installed rubytree-0.7.0 | |
Successfully installed i18n-0.6.0 | |
Successfully installed multi_json-1.0.4 | |
Successfully installed activesupport-3.2.1 | |
Successfully installed net-ldap-0.1.1 | |
Successfully installed castanet-1.0.1 | |
Successfully installed rack-1.4.1 | |
Successfully installed warden-1.1.0 | |
Successfully installed aker-3.0.3 | |
9 gems installed | |
gem list with gemjar required: | |
*** LOCAL GEMS *** | |
activesupport (3.2.1) | |
aker (3.0.3) | |
castanet (1.0.1) | |
i18n (0.6.0) | |
multi_json (1.0.4) | |
net-ldap (0.1.1) | |
rack (1.4.1) | |
rubytree (0.7.0) | |
warden (1.1.0) | |
gem list with gemjar on classpath: | |
*** LOCAL GEMS *** | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment