Created
September 29, 2010 19:01
-
-
Save yokolet/603328 to your computer and use it in GitHub Desktop.
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
- Install Bundler | |
> jruby -S gem install bundle --no-ri --no-rdoc | |
- Create and Edit Gemfile | |
> cd [some directory to install gems] | |
> jruby -S bundle init | |
> vim Gemfile | |
# A sample Gemfile | |
source "http://rubygems.org" | |
# gem "rails" | |
gem "dm-core" | |
gem "dm-timestamps" | |
gem "dm-sqlite-adapter" | |
- Install gems to vendor directory | |
> jruby -S bundle install --path=vendor | |
- Write Java code with JRuby embed | |
String basepath = System.getProperty("user.dir"); | |
ScriptingContainer container = new ScriptingContainer(LocalContextScope.SINGLETHREAD); | |
container.setHomeDirectory("/Users/yoko/Tools/jruby-1.5.3"); // needs for "require 'rubygems'" | |
System.out.println("jrubyhome: " + container.getHomeDirectory()); | |
// tell jruby where the Gemfile is located. | |
container.runScriptlet("ENV['BUNDLE_GEMFILE'] = \"" + basepath + "/build/ruby/Gemfile\""); | |
container.runScriptlet("require 'rubygems'"); | |
container.runScriptlet("require 'bundler/setup'"); | |
container.runScriptlet("Bundler.require"); | |
container.runScriptlet("require 'dm-core'"); | |
container.runScriptlet("require 'dm-timestamps'"); | |
container.runScriptlet("DataMapper.setup(:default, 'sqlite::memory:')"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment