mirror of
https://github.com/elastic/logstash.git
synced 2025-04-21 21:27:20 -04:00
* Exclude plugins feature in OSS distributions. * Set elastic_integration plugin default. * Remove non-OSS plugins after installing default plugins. * Testing local can't find gem bundler (= 2.3.26) issue. * Include extract non-OSS plugins logic indocker build operations. * Only default plugins can be excluded from OSS distros. * Simplification: instead conditional check, use intersection to make OSS exlucluded plugin list. * Gem and specification files still stay after removing the plugin. This change removes the stayed files. * Rename oss-exclude to skip-oss to align namings with other params. * Make intersection method simpler. * [Test] Temporary excluding elastic integration plugin from default plugin list. * Sets elastic_integration plugin default back. When removing locally installed gems, Gem::Specification doesn't recognize the gem. We have Bundle::setup in the removal logic but it is causing an issue when we re-use the bundle. * Test the build order, remove plugin from cache logic seems invalid since we don't pack the cache.
124 lines
4.2 KiB
Ruby
124 lines
4.2 KiB
Ruby
# Licensed to Elasticsearch B.V. under one or more contributor
|
|
# license agreements. See the NOTICE file distributed with
|
|
# this work for additional information regarding copyright
|
|
# ownership. Elasticsearch B.V. licenses this file to you under
|
|
# the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing,
|
|
# software distributed under the License is distributed on an
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
# KIND, either express or implied. See the License for the
|
|
# specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
require_relative "default_plugins"
|
|
require 'rubygems'
|
|
|
|
namespace "plugin" do
|
|
def install_plugins(*args)
|
|
require_relative "../lib/pluginmanager/main"
|
|
LogStash::PluginManager::Main.run("bin/logstash-plugin", ["install"] + args)
|
|
end
|
|
|
|
def remove_plugin(plugin)
|
|
require_relative "../lib/pluginmanager/main"
|
|
LogStash::PluginManager::Main.run("bin/logstash-plugin", ["remove", plugin])
|
|
end
|
|
|
|
task "install-base" => "bootstrap" do
|
|
puts("[plugin:install-base] Installing base dependencies")
|
|
install_plugins("--development", "--preserve")
|
|
task.reenable # Allow this task to be run again
|
|
end
|
|
|
|
def remove_lockfile
|
|
if ::File.exist?(LogStash::Environment::LOCKFILE)
|
|
::File.delete(LogStash::Environment::LOCKFILE)
|
|
end
|
|
end
|
|
|
|
task "install-development-dependencies" => "bootstrap" do
|
|
puts("[plugin:install-development-dependencies] Installing development dependencies")
|
|
install_plugins("--development", "--preserve")
|
|
install_plugins("--preserve", *LogStash::RakeLib::CORE_SPECS_PLUGINS)
|
|
|
|
task.reenable # Allow this task to be run again
|
|
end
|
|
|
|
task "install", :name do |task, args|
|
|
name = args[:name]
|
|
puts("[plugin:install] Installing plugin: #{name}")
|
|
install_plugins("--no-verify", "--preserve", name)
|
|
|
|
task.reenable # Allow this task to be run again
|
|
end # task "install"
|
|
|
|
task "install-default" => "bootstrap" do
|
|
puts("[plugin:install-default] Installing default plugins")
|
|
|
|
remove_lockfile # because we want to use the release lockfile
|
|
install_plugins("--no-verify", "--preserve", *LogStash::RakeLib::DEFAULT_PLUGINS)
|
|
|
|
task.reenable # Allow this task to be run again
|
|
end
|
|
|
|
task "remove-non-oss-plugins" do |task, _|
|
|
puts("[plugin:remove-non-oss-plugins] Removing non-OSS plugins")
|
|
|
|
LogStash::RakeLib::OSS_EXCLUDED_PLUGINS.each do |plugin|
|
|
remove_plugin(plugin)
|
|
# gem folder and spec file still stay after removing the plugin
|
|
FileUtils.rm_r(Dir.glob("#{LogStash::Environment::BUNDLE_DIR}/**/gems/#{plugin}*"))
|
|
FileUtils.rm_r(Dir.glob("#{LogStash::Environment::BUNDLE_DIR}/**/specifications/#{plugin}*.gemspec"))
|
|
end
|
|
task.reenable # Allow this task to be run again
|
|
end
|
|
|
|
task "clean-local-core-gem", [:name, :path] do |task, args|
|
|
name = args[:name]
|
|
path = args[:path]
|
|
|
|
Dir[File.join(path, "#{name}*.gem")].each do |gem|
|
|
puts("[plugin:clean-local-core-gem] Cleaning #{gem}")
|
|
rm(gem)
|
|
end
|
|
|
|
task.reenable # Allow this task to be run again
|
|
end
|
|
|
|
task "build-local-core-gem", [:name, :path] => ["build/gems"] do |task, args|
|
|
name = args[:name]
|
|
path = args[:path]
|
|
|
|
Rake::Task["plugin:clean-local-core-gem"].invoke(name, path)
|
|
|
|
puts("[plugin:build-local-core-gem] Building #{File.join(path, name)}.gemspec")
|
|
|
|
gem_path = nil
|
|
Dir.chdir(path) do
|
|
spec = Gem::Specification.load("#{name}.gemspec")
|
|
gem_path = Gem::Package.build(spec)
|
|
end
|
|
FileUtils.cp(File.join(path, gem_path), "build/gems/")
|
|
|
|
task.reenable # Allow this task to be run again
|
|
end
|
|
|
|
task "install-local-core-gem", [:name, :path] do |task, args|
|
|
name = args[:name]
|
|
path = args[:path]
|
|
|
|
Rake::Task["plugin:build-local-core-gem"].invoke(name, path)
|
|
|
|
gems = Dir[File.join(path, "#{name}*.gem")]
|
|
abort("ERROR: #{name} gem not found in #{path}") if gems.size != 1
|
|
puts("[plugin:install-local-core-gem] Installing #{gems.first}")
|
|
install_plugins("--no-verify", gems.first)
|
|
|
|
task.reenable # Allow this task to be run again
|
|
end
|
|
end # namespace "plugin"
|