logstash/logstash-core-plugin-api/logstash-core-plugin-api.gemspec
Dimitrios Liappis c7204fd7d6
Don't honor VERSION_QUALIFIER if set but empty (#17032)
PR #17006 revealed that the `VERSION_QUALIFIER` env var gets honored in
various scripts when present but empty.
This shouldn't be the case as the DRA process is designed to gracefully
ignore empty values for this variable.

This commit changes various ruby scripts to not treat "" as truthy.
Bash scripts (used by CI etc.) are already ok with this as part of
refactorings done in #16907.

---------

Co-authored-by: Andrea Selva <selva.andre@gmail.com>
2025-02-07 13:05:23 +02:00

55 lines
2.3 KiB
Ruby

# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
project_versions_yaml_path = File.expand_path("../versions.yml", File.dirname(__FILE__))
if File.exist?(project_versions_yaml_path)
# we need to copy the project level versions.yml into the gem root
# to be able to package it into the gems file structure
# as the require 'logstash-core-plugin-api/version' loads the yaml file from within the gem root.
#
# we ignore the copy in git and we overwrite an existing file
# each time we build the logstash-core gem
original_lines = IO.readlines(project_versions_yaml_path)
# introduce the version qualifier (e.g. beta1, rc1) into the copied yml so it's displayed by Logstash
unless ENV['VERSION_QUALIFIER'].to_s.strip.empty?
logstash_version_line = original_lines.find {|line| line.match(/^logstash:/) }
logstash_version_line.chomp!
logstash_version_line << "-#{ENV['VERSION_QUALIFIER']}\n"
end
original_lines << "\n"
original_lines << "# This is a copy the project level versions.yml into this gem's root and it is created when the gemspec is evaluated."
gem_versions_yaml_path = File.expand_path("./versions-gem-copy.yml", File.dirname(__FILE__))
File.open(gem_versions_yaml_path, 'w') do |new_file|
# create or overwrite
new_file.puts(original_lines)
end
end
require "logstash-core-plugin-api/version"
Gem::Specification.new do |gem|
gem.authors = ["Elastic"]
gem.email = ["info@elastic.co"]
gem.description = %q{Logstash plugin API}
gem.summary = %q{Define the plugin API that the plugin need to follow.}
gem.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
gem.license = "Apache-2.0"
gem.files = Dir.glob(["logstash-core-plugin-api.gemspec", "lib/**/*.rb", "spec/**/*.rb"])
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.name = "logstash-core-plugin-api"
gem.require_paths = ["lib"]
gem.version = LOGSTASH_CORE_PLUGIN_API
gem.add_runtime_dependency "logstash-core", LOGSTASH_CORE_VERSION.gsub("-", ".")
# Make sure we dont build this gem from a non jruby
# environment.
if RUBY_PLATFORM == "java"
gem.platform = "java"
else
raise "The logstash-core-api need to be build on jruby"
end
end