-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathRakefile
54 lines (46 loc) · 1.27 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# frozen_string_literal: true
require "set"
require "rake/clean"
require "rake/testtask"
# Directory to place gems to bundle with our main gem
PACKAGE_DIR = "pkg"
CLOBBER.include PACKAGE_DIR
desc "Copies gem dependencies to the #{PACKAGE_DIR} folder"
task "gemdep" do
gem_copy gen_gem_list
end
desc "Copies gem dependencies which don't overlap with td-agent to the #{PACKAGE_DIR} folder"
task "gemdep:minimal" do
MINIMAL_GEMS = %w[
unf_ext
unf
domain_name
http-cookie
http-form_data
http
].freeze
gem_copy gen_gem_list MINIMAL_GEMS
end
def gen_gem_list(subset = [])
myself = Bundler.load_gemspec(Dir[File.join(Bundler::SharedHelpers.pwd, "{,*}.gemspec")].first)
to_pull = Set[]
Bundler.locked_gems.specs.each do |spec|
next if spec.name == myself.name
if subset.empty?
to_pull.add(spec)
elsif subset.include? spec.name
to_pull.add(spec)
end
end
to_pull
end
# This assumes that bundle install has already been run (which populates
# Bundler.app_cache with the gems of dependencies).
def gem_copy(specs)
Bundler.mkdir_p PACKAGE_DIR
sources = specs.map { |s| Bundler.app_cache.join "#{s.full_name}.gem" }
FileUtils.cp sources, PACKAGE_DIR, verbose: true
end
Rake::TestTask.new do |task|
task.pattern = "test/**/*.rb"
end