mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
parent
3594f18071
commit
3cb1aa8658
4 changed files with 66 additions and 21 deletions
49
lib/logstash/bundler_patch.rb
Normal file
49
lib/logstash/bundler_patch.rb
Normal file
|
@ -0,0 +1,49 @@
|
|||
require 'bundler'
|
||||
|
||||
module Bundler
|
||||
class RubygemsIntegration
|
||||
# When you call Bundler#setup it will bootstrap
|
||||
# a new rubygems environment and wipe all the existing
|
||||
# specs available if they are not defined in the current gemfile.
|
||||
# This patch change the behavior and will merge the specs.
|
||||
#
|
||||
# If you use :path to declare a gem in your gemfile this will create
|
||||
# a virtual specs for this gems and add will add them to the $LOAD_PATH
|
||||
#
|
||||
# Future >= rubygems 2.0
|
||||
class Future < RubygemsIntegration
|
||||
def stub_rubygems(specs)
|
||||
merged = merge_specs(specs)
|
||||
|
||||
Gem::Specification.all = merged
|
||||
|
||||
Gem.post_reset {
|
||||
Gem::Specification.all = merged
|
||||
}
|
||||
end
|
||||
|
||||
def merge_specs(specs)
|
||||
merged_array = Gem::Specification.to_a + specs.to_a
|
||||
SpecSet.new(merged_array)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Patch bundler to write a .lock file specific to the version of ruby.
|
||||
# This keeps MRI/JRuby/RBX from conflicting over the Gemfile.lock updates
|
||||
module SharedHelpers
|
||||
def default_lockfile
|
||||
ruby = "#{LogStash::Environment.ruby_engine}-#{LogStash::Environment.ruby_abi_version}"
|
||||
Pathname.new("#{default_gemfile}.#{ruby}.lock")
|
||||
end
|
||||
end
|
||||
|
||||
# Add the Bundler.reset! method which has been added in master but is not in 1.7.9.
|
||||
class << self
|
||||
unless self.method_defined?("reset!")
|
||||
def reset!
|
||||
@definition = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -57,6 +57,22 @@ module LogStash
|
|||
# of some plugins dependedant gems.
|
||||
def set_gem_paths!
|
||||
ENV["GEM_HOME"] = ENV["GEM_PATH"] = logstash_gem_home
|
||||
ENV["BUNDLE_GEMFILE"] = GEMFILE_PATH
|
||||
|
||||
require 'bundler'
|
||||
require 'logstash/bundler_patch'
|
||||
|
||||
Bundler.setup
|
||||
|
||||
# Bundler.setup will wipe the existing $LOAD_PATH.
|
||||
# Since we are using gems not declared in the gemfile we need to
|
||||
# recalculate the $LOAD_PATH with all the available gems
|
||||
load_paths = Gem::Specification
|
||||
.collect(&:load_paths)
|
||||
.flatten
|
||||
.reject { |path| $LOAD_PATH.include?(path) }
|
||||
|
||||
$LOAD_PATH.unshift(*load_paths)
|
||||
end
|
||||
|
||||
def bundler_install_command(gem_file, gem_path)
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
module Bundler
|
||||
|
||||
# Patch bundler to write a .lock file specific to the version of ruby.
|
||||
# This keeps MRI/JRuby/RBX from conflicting over the Gemfile.lock updates
|
||||
module SharedHelpers
|
||||
def default_lockfile
|
||||
ruby = "#{LogStash::Environment.ruby_engine}-#{LogStash::Environment.ruby_abi_version}"
|
||||
Pathname.new("#{default_gemfile}.#{ruby}.lock")
|
||||
end
|
||||
end
|
||||
|
||||
# Add the Bundler.reset! method which has been added in master but is not in 1.7.9.
|
||||
class << self
|
||||
unless self.method_defined?("reset!")
|
||||
def reset!
|
||||
@definition = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,7 +3,7 @@ namespace "dependency" do
|
|||
task "bundler" do
|
||||
Rake::Task["gem:require"].invoke("bundler", ">= 1.3.5", LogStash::Environment.logstash_gem_home)
|
||||
require "bundler/cli"
|
||||
require_relative "bundler_patch"
|
||||
require "logstash/bundler_patch"
|
||||
end
|
||||
|
||||
task "rbx-stdlib" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue