From d2553f094845dc126e7de4698d18fae47f2b1f3a Mon Sep 17 00:00:00 2001 From: Daijiro Fukuda Date: Thu, 20 Jun 2024 19:49:42 +0900 Subject: [PATCH] gemspec: Remove unnecessary files from Gem This reduces Gem file size: 867k -> 558k Remove: * test files * git files * Gemfile `test_files` is not documented anymore: * https://guides.rubygems.org/specification-reference Looks like it is not recommended: * https://github.com/rubygems/bundler/pull/3207 Looks like we should also remove git files and Gemfile because the template of Bundler 2.4.13 is as follows: spec.files = Dir.chdir(__dir__) do `git ls-files -z`.split("\x0").reject do |f| (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile]) end end The removed files except for `test/*` are as follows: before = `git ls-files`.split($\) after = Dir.chdir(__dir__) do `git ls-files -z`.split("\x0").reject do |f| (File.expand_path(f) == __FILE__) || f.start_with?(*%w[test/ .git Gemfile]) end end before.reject{|path| path.start_with? "test/"}.difference after => [".github/DISCUSSION_TEMPLATE/q-a-japanese.yml", ".github/DISCUSSION_TEMPLATE/q-a.yml", ".github/ISSUE_TEMPLATE.md", ".github/ISSUE_TEMPLATE/bug_report.yml", ".github/ISSUE_TEMPLATE/config.yml", ".github/ISSUE_TEMPLATE/feature_request.yml", ".github/PULL_REQUEST_TEMPLATE.md", ".github/workflows/stale-actions.yml", ".github/workflows/test-ruby-head.yml", ".github/workflows/test.yml", ".gitignore", "Gemfile"] after.difference before => [] Signed-off-by: Daijiro Fukuda --- fluentd.gemspec | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fluentd.gemspec b/fluentd.gemspec index e3ecf22f3c..bd9a3ac9d0 100644 --- a/fluentd.gemspec +++ b/fluentd.gemspec @@ -10,9 +10,13 @@ Gem::Specification.new do |gem| gem.summary = %q{Fluentd event collector} gem.homepage = "https://www.fluentd.org/" - gem.files = `git ls-files`.split($\) + gem.files = Dir.chdir(__dir__) do + `git ls-files -z`.split("\x0").reject do |f| + (File.expand_path(f) == __FILE__) || + f.start_with?(*%w[test/ .git Gemfile]) + end + end gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } - gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] gem.license = "Apache-2.0"