lib/jarbler/builder.rb in jarbler-0.1.1 vs lib/jarbler/builder.rb in jarbler-0.1.2
- old
+ new
@@ -84,32 +84,32 @@
# Find the locations where Gems are installed
# @param [String] app_root Application root directory
# @return [Array] Array of Gem locations
def collect_gem_search_locations(app_root)
- # Search locations of gems in Gemfile.lock
- possible_gem_search_locations = []
- # Add possible local config first in search list
- possible_gem_search_locations << bundle_config_bundle_path(app_root) if bundle_config_bundle_path(app_root)
- ENV['GEM_PATH'].split(':').each do |gem_path|
- possible_gem_search_locations << gem_path
- end
+ # All active search locations for Gems
+ Bundler.setup
+ possible_gem_search_locations = Gem.paths.path
debug "Possible Gem locations: #{possible_gem_search_locations}"
gem_search_locations = []
# Check where inside this location the gems may be installed
possible_gem_search_locations.each do |gem_search_location|
- valid_gem_search_location = nil # No valid path found yet
- Find.find(gem_search_location) do |path|
- if File.directory?(path) && File.exist?("#{path}/specifications") && File.exist?("#{path}/gems")
- valid_gem_search_location = path # Found a valid path
- Find.prune # Do not search deeper
+ if File.exist?(gem_search_location) && File.directory?(gem_search_location)
+ valid_gem_search_location = nil # No valid path found yet
+ Find.find(gem_search_location) do |path|
+ if File.directory?(path) && File.exist?("#{path}/specifications") && File.exist?("#{path}/gems")
+ valid_gem_search_location = path # Found a valid path
+ Find.prune # Do not search deeper
+ end
end
- end
- if valid_gem_search_location
- gem_search_locations << valid_gem_search_location
+ if valid_gem_search_location
+ gem_search_locations << valid_gem_search_location
+ else
+ debug "No valid gem location found in #{gem_search_location}"
+ end
else
- debug "No valid gem location found in #{gem_search_location}"
+ debug("Gem location #{gem_search_location} does not exist or is not a directory")
end
end
debug "Valid Gem locations: #{gem_search_locations}"
gem_search_locations
end
@@ -191,23 +191,10 @@
debug ""
end
@config
end
- # Check if there is an additional local bundle path in .bundle/config
- def bundle_config_bundle_path(rails_root)
- bundle_path = nil # default
- if File.exist?("#{rails_root}/.bundle/config")
- bundle_config = YAML.load_file("#{rails_root}/.bundle/config")
- if bundle_config && bundle_config['BUNDLE_PATH']
- bundle_path = "#{rails_root}/#{bundle_config['BUNDLE_PATH']}"
- debug "Local Gem path configured in #{rails_root}/.bundle/config: #{bundle_path}"
- end
- end
- bundle_path
- end
-
# Copy the jruby-jars to the staging directory
# @param [String] staging_dir Path to the staging directory
# @param [Array] gem_search_locations Array of Gem locations to look for jRuby jars
# @return [String] the ruby version of the jRuby jars
def copy_jruby_jars_to_staging(staging_dir, gem_search_locations)
@@ -217,10 +204,10 @@
if File.exist?(gem_dir)
jruby_jars_location = gem_dir
break
end
end
- raise "Could not determine location of jRuby jars for release '#{config.jruby_version}' in the following output:\n#{lines}" unless jruby_jars_location
+ raise "Could not determine location of jRuby jars for release '#{config.jruby_version}' in the following locations:\n#{gem_search_locations}" unless jruby_jars_location
file_utils_copy("#{jruby_jars_location}/lib/jruby-core-#{config.jruby_version}-complete.jar", staging_dir)
file_utils_copy("#{jruby_jars_location}/lib/jruby-stdlib-#{config.jruby_version}.jar", staging_dir)
# Get the according Ruby version for the current jRuby version
lines = exec_command "java -cp #{jruby_jars_location}/lib/jruby-core-#{config.jruby_version}-complete.jar org.jruby.Main --version"
\ No newline at end of file