forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract_services.rb
29 lines (25 loc) · 774 Bytes
/
extract_services.rb
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
# Extract META-INFO/services/* files from jars
#
require "optparse"
output = nil
flags = OptionParser.new do |opts|
opts.on("-o", "--output DIR",
"Where to write the merged META-INF/services/* files") do |dir|
output = dir
end
end
flags.parse!(ARGV)
ARGV.each do |jar|
# Find any files matching /META-INF/services/* in any jar given on the
# command line.
# Append all file content to the output directory with the same file name
# as is in the jar.
glob = "file:///#{File.expand_path(jar)}!/META-INF/services/*"
Dir.glob(glob).each do |service|
name = File.basename(service)
File.open(File.join(output, name), "a") do |fd|
puts "Adding #{name} from #{File.basename(jar)}"
fd.write(File.read(service))
end
end
end