-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
97 lines (81 loc) · 2.82 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
require "logstash/devutils/rake"
require 'rubygems'
require 'rubygems/package_task'
require 'fileutils'
require 'rspec/core/rake_task'
# Please read BUILD_INSTRUCTIONS.md
def check_gemspec_version
root_dir = File.dirname(__FILE__)
recursive_remove_version = File.read(File.expand_path(File.join(root_dir, "VERSION"))).strip
gemspec = File.read(File.expand_path(File.join(root_dir, "logstash-filter-recursive_remove.gemspec")))
spec_version = eval(gemspec, TOPLEVEL_BINDING).version.to_s
recursive_remove_version == spec_version
end
desc "Compile and vendor java into ruby"
task :vendor => [:bundle_install] do
puts "-------------------> checking gemspec version matches VERSION file"
exit(1) unless check_gemspec_version
exit(1) unless system './gradlew check vendor'
puts "-------------------> vendored recursive_remove jar via rake"
end
desc "Compile and vendor java into ruby for travis, its done bundle install already"
task :travis_vendor => [:write_gradle_properties] do
puts "-------------------> checking gemspec version matches VERSION file"
exit(1) unless check_gemspec_version
exit(1) unless system './gradlew check vendor'
puts "-------------------> vendored recursive_remove jar via rake"
end
desc "Do bundle install and write gradle.properties"
task :bundle_install do
`bundle install`
delete_create_gradle_properties
end
desc "Write gradle.properties" # used by travis
task :write_gradle_properties do
delete_create_gradle_properties
end
spec = Gem::Specification.load('logstash-filter-recursive_remove.gemspec')
Gem::PackageTask.new(spec) do
desc 'Package gem'
task :package => [:vendor]
end
RSpec::Core::RakeTask.new(:spec)
task :check => [:vendor, :spec]
task :travis_test => [:travis_vendor, :spec]
desc "Run full check with custom Logstash path"
task :custom_ls_check, :ls_dir do |task, args|
ls_path = args[:ls_dir]
system(custom_ls_path_shell_script(ls_path))
end
def custom_ls_path_shell_script(path)
<<TXT
export LOGSTASH_PATH='#{path}'
export LOGSTASH_SOURCE=1
bundle install
bundle exec rake travis_vendor
bundle exec rspec spec
TXT
end
def delete_create_gradle_properties
root_dir = File.dirname(__FILE__)
gradle_properties_file = "#{root_dir}/gradle.properties"
lsc_path = `bundle show logstash-core`.split(/\n/).last
#FileUtils.rm_f(gradle_properties_file)
#File.open(gradle_properties_file, "w") do |f|
# f.puts "logstashCoreGemPath=#{lsc_path}"
#end
lsc_path_exists = false
File.open(gradle_properties_file, "r") do |f|
existingContents = f.read
if existingContents.include? lsc_path
lsc_path_exists = true
end
end
if lsc_path_exists == false
File.open(gradle_properties_file, "a") do |f|
f.puts "logstashCoreGemPath=#{lsc_path}"
end
end
puts "-------------------> Wrote #{gradle_properties_file}"
puts `cat #{gradle_properties_file}`
end