forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
executable file
·158 lines (130 loc) · 4.89 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
require 'tempfile'
require 'ftools'
LOGSTASH_VERSION = "0.9.1"
# Compile config grammar (ragel -> ruby)
file "lib/logstash/config/grammar.rb" => ["lib/logstash/config/grammar.rl"] do
sh "make -C lib/logstash/config grammar.rb"
end
# Taken from 'jrubyc'
# Currently this code is commented out because jruby emits this:
# Failure during compilation of file logstash/web/helpers/require_param.rb:
# java.lang.RuntimeException: java.io.FileNotFoundException: File path
# /home/jls/projects/logstash/logstash/web/helpers/require_param.rb
# does not start with parent path /home/jls/projects/logstash/lib
#
# org/jruby/util/JavaNameMangler.java:105:in `mangleFilenameForClasspath'
# org/jruby/util/JavaNameMangler.java:32:in `mangleFilenameForClasspath'
#require 'jruby/jrubyc'
##args = [ "-p", "net.logstash" ]
#args = ["-d", "build"]
#args += Dir.glob("**/*.rb")
#status = JRuby::Compiler::compile_argv(args)
#if (status != 0)
#puts "Compilation FAILED: #{status} error(s) encountered"
#exit status
#end
task :compile => "lib/logstash/config/grammar.rb" do |t|
mkdir_p "build"
sh "rm -rf lib/net"
Dir.chdir("lib") do
args = Dir.glob("**/*.rb")
sh "jrubyc", "-t", "../build", *args
end
end
VERSIONS = {
:jruby => "1.6.0", # Any of CPL1.0/GPL2.0/LGPL2.1 ? Confusing, but OK.
:elasticsearch => "0.15.2", # Apache 2.0 license
:joda => "1.6.2", # Apache 2.0 license
}
namespace :vendor do
file "vendor/jar" do |t|
mkdir_p t.name
end
# Download jruby.jar
file "vendor/jar/jruby-complete-#{VERSIONS[:jruby]}.jar" => "vendor/jar" do |t|
baseurl = "http://repository.codehaus.org/org/jruby/jruby-complete"
if !File.exists?(t.name)
sh "wget -O #{t.name} #{baseurl}/#{VERSIONS[:jruby]}/#{File.basename(t.name)}"
end
end # jruby
task :jruby => "vendor/jar/jruby-complete-#{VERSIONS[:jruby]}.jar" do
# nothing to do, the dep does it.
end
# Download elasticsearch + deps (for outputs/elasticsearch)
task :elasticsearch => "vendor/jar" do
version = VERSIONS[:elasticsearch]
tarball = "elasticsearch-#{version}.tar.gz"
url = "http://github.com/downloads/elasticsearch/elasticsearch/#{tarball}"
if !File.exists?(tarball)
# --no-check-certificate is for github and wget not supporting wildcard
# certs sanely.
sh "wget -O #{tarball} --no-check-certificate #{url}"
end
sh "tar -zxf #{tarball} -C vendor/jar/ elasticsearch-#{version}/lib"
end # elasticsearch
task :joda => "vendor/jar" do
version = VERSIONS[:joda]
baseurl = "http://sourceforge.net/projects/joda-time/files/joda-time"
tarball = "joda-time-#{version}-bin.tar.gz"
url = "#{baseurl}/#{version}/#{tarball}/download"
if !File.exists?(tarball)
sh "wget -O #{tarball} #{url}"
end
sh "tar -zxf #{tarball} -C vendor/jar/ joda-time-#{version}/joda-time-#{version}.jar"
end # joda
task :gems => "vendor/jar" do
puts "=> Installing gems to vendor/bundle/..."
sh "bundle install --deployment"
end
end # vendor namespace
namespace :package do
task :gem do
sh "gem build logstash.gemspec"
end
monolith_deps = [ "vendor:jruby", "vendor:gems", "vendor:elasticsearch", "compile" ]
namespace :monolith do
task :tar => monolith_deps do
paths = %w{ bin CHANGELOG CONTRIBUTORS etc examples Gemfile Gemfile.lock
INSTALL lib LICENSE patterns Rakefile README.md STYLE.md test
TODO USAGE vendor/bundle vendor/jar }
sh "tar -zcf logstash-monolithic-someversion.tar.gz #{paths.join(" ")}"
end # package:monolith:tar
task :jar => monolith_deps do
mkdir_p "build-jar"
# Unpack all the 3rdparty jars
Dir.glob("vendor/jar/**/*.jar").each do |jar|
puts "=> Unpacking #{jar} into build-jar/"
Dir.chdir("build-jar") do
sh "jar xf ../#{jar}"
end
end
# We compile stuff to build/...
Dir.glob("build/**/*.class").each do |file|
target = File.join("build-jar", file.gsub("build/", ""))
mkdir_p File.dirname(target)
puts "=> Copying #{file} => #{target}"
File.copy(file, target)
end
output = "logstash-#{LOGSTASH_VERSION}.jar"
sh "jar -cfe #{output} logstash.agent -C build-jar ."
# Learned how to do this mostly from here:
# http://blog.nicksieger.com/articles/2009/01/10/jruby-1-1-6-gems-in-a-jar
# Add bundled gems to the jar
sh "jar uf #{output} -C vendor/bundle/jruby/1.8 ."
# Add grok patterns
sh "jar -uf #{output} patterns/"
# Build jar index
sh "jar -i #{output}"
end # package:monolith:jar
end # monolith
end # package
task :test do
sh "cd test; ruby run.rb"
end
# No publishing until 1.0! :)
#task :publish do
#latest_gem = %x{ls -t logstash-[0-9]*.gem}.split("\n").first
#sh "gem push #{latest_gem}"
#latest_lite_gem = %x{ls -t logstash-lite*.gem}.split("\n").first
#sh "gem push #{latest_lite_gem}"
#end