Skip to content

Commit

Permalink
Add jruby.gem.(path|home) property support for rubygems. (Take 2)
Browse files Browse the repository at this point in the history
Fix for JRUBY-4729.

Signed-off-by: Nick Sieger <nick@nicksieger.com>
  • Loading branch information
dekellum authored and nicksieger committed Apr 21, 2010
1 parent 3b9aa6c commit ba6b3e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/ruby/site_ruby/1.8/rubygems/defaults/jruby.rb
@@ -1,4 +1,5 @@
require 'rubygems/config_file'
require 'rbconfig'

module Gem

Expand All @@ -22,7 +23,9 @@ def set_paths(gpaths)

alias_method :original_default_path, :default_path
def default_path
paths = original_default_path
paths = RbConfig::CONFIG["default_gem_path"]
paths = paths.split(':').reject {|p| p.empty? }.compact if paths
paths ||= original_default_path
@jar_paths = paths.select {|p| jarred_path? p }
paths.reject {|p| jarred_path? p }
end
Expand Down Expand Up @@ -51,7 +54,9 @@ def jarred_path?(p)
# JRuby: We don't want gems installed in lib/jruby/gems, but rather
# to preserve the old location: lib/ruby/gems.
def self.default_dir
File.join ConfigMap[:libdir], 'ruby', 'gems', '1.8'
dir = RbConfig::CONFIG["default_gem_home"]
dir ||= File.join(ConfigMap[:libdir], 'ruby', 'gems', '1.8')
dir
end

##
Expand Down
6 changes: 6 additions & 0 deletions src/org/jruby/libraries/RbConfigLibrary.java
Expand Up @@ -206,6 +206,12 @@ public void load(Ruby runtime, boolean wrap) {
if (runtime.is1_9()) {
setConfig(configHash, "ridir", new NormalizedFile(shareDir, "ri").getPath());
}

// These will be used as jruby defaults for rubygems if found
String gemhome = SafePropertyAccessor.getProperty("jruby.gem.home");
String gempath = SafePropertyAccessor.getProperty("jruby.gem.path");
if (gemhome != null) setConfig(configHash, "default_gem_home", gemhome);
if (gempath != null) setConfig(configHash, "default_gem_path", gempath);

RubyHash mkmfHash = RubyHash.newHash(runtime);

Expand Down

0 comments on commit ba6b3e3

Please sign in to comment.