redstorm 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +11 -1
- data/README.md +162 -100
- data/examples/simple/redis_word_count_topology.rb +4 -4
- data/examples/simple/ruby_version_topology.rb +4 -4
- data/examples/simple/word_count_bolt.rb +1 -1
- data/lib/red_storm.rb +1 -37
- data/lib/red_storm/application.rb +14 -11
- data/lib/red_storm/configurator.rb +3 -2
- data/lib/red_storm/environment.rb +27 -17
- data/lib/red_storm/simple_topology.rb +11 -13
- data/lib/red_storm/topology_launcher.rb +3 -26
- data/lib/red_storm/version.rb +1 -1
- data/lib/tasks/red_storm.rake +100 -87
- metadata +119 -112
- data/TODO.md +0 -1
- data/pom.xml +0 -71
data/lib/red_storm.rb
CHANGED
@@ -1,42 +1,6 @@
|
|
1
|
-
# this is the entry point for these two contexts:
|
2
|
-
# - running red_storm.rake
|
3
|
-
# - at remote cluster topology execution. Once topology_launcher.rb has submitted the topology
|
4
|
-
# the spouts and bolts classes will be instanciated and will require red_storm.rb
|
5
|
-
|
6
|
-
# we depends on rubygems begings loaded at this point for setting up gem/bundle environments
|
7
|
-
# explicitely requiring rubygems is required in remote cluster environment
|
8
1
|
require 'rubygems'
|
9
2
|
|
10
|
-
|
11
|
-
# this is required here and in topology_launcher.rb which are both
|
12
|
-
# entry points in redstorm.
|
13
|
-
module RedStorm
|
14
|
-
TOPOLOGY_LAUNCHED = defined?(LAUNCH_PATH)
|
15
|
-
|
16
|
-
# do not redefine if already defined in topology_launcher.rb
|
17
|
-
unless TOPOLOGY_LAUNCHED
|
18
|
-
LAUNCH_PATH = File.expand_path(File.dirname(__FILE__))
|
19
|
-
JAR_CONTEXT = !!(LAUNCH_PATH =~ /\.jar!$/)
|
20
|
-
|
21
|
-
if JAR_CONTEXT
|
22
|
-
BASE_PATH = LAUNCH_PATH
|
23
|
-
else
|
24
|
-
BASE_PATH = Dir.pwd
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
unless RedStorm::JAR_CONTEXT
|
30
|
-
# in JAR context red_storm.rb and red_storm/* is in the JAR root.
|
31
|
-
# otherwise this is in lib/...
|
32
|
-
$:.unshift "#{RedStorm::BASE_PATH}/lib"
|
33
|
-
end
|
34
|
-
|
35
|
-
unless RedStorm::TOPOLOGY_LAUNCHED
|
36
|
-
require 'red_storm/environment'
|
37
|
-
RedStorm.setup_gems if RedStorm::JAR_CONTEXT
|
38
|
-
end
|
39
|
-
|
3
|
+
require 'red_storm/environment'
|
40
4
|
require 'red_storm/version'
|
41
5
|
require 'red_storm/configuration'
|
42
6
|
require 'red_storm/application'
|
@@ -1,31 +1,33 @@
|
|
1
1
|
module RedStorm
|
2
|
-
|
3
|
-
DEFAULT_RUBY_VERSION = "--1.8"
|
4
|
-
RUNTIME = {}
|
5
2
|
|
6
3
|
class Application
|
7
4
|
TASKS_FILE = "#{RedStorm::REDSTORM_HOME}/lib/tasks/red_storm.rake"
|
8
5
|
|
9
6
|
def usage
|
10
|
-
puts("usage: redstorm
|
7
|
+
puts("usage: redstorm install")
|
8
|
+
puts(" redstorm deps")
|
9
|
+
puts(" redstorm build")
|
10
|
+
puts(" redstorm examples")
|
11
|
+
puts(" redstorm bundle [BUNDLER_GROUP]")
|
12
|
+
puts(" redstorm jar DIR1, [DIR2, ...]")
|
13
|
+
puts(" redstorm local [--1.8|--1.9] TOPOLOGY_CLASS_PATH")
|
14
|
+
puts(" redstorm cluster [--1.8|--1.9] TOPOLOGY_CLASS_PATH")
|
11
15
|
exit(1)
|
12
16
|
end
|
13
17
|
|
14
18
|
def run(args)
|
15
19
|
if args.size > 0
|
16
|
-
|
17
|
-
RUNTIME['RUBY_VERSION'] = version
|
18
|
-
|
19
|
-
if ["install", "examples", "jar", "gems", "bundle", "deps", "build"].include?(args[0])
|
20
|
+
if ["install", "examples", "jar", "bundle", "deps", "build"].include?(args[0])
|
20
21
|
load(TASKS_FILE)
|
21
22
|
Rake::Task[args.shift].invoke(args.join(":"))
|
22
23
|
exit
|
23
|
-
elsif args.size >= 2 &&
|
24
|
-
args.
|
24
|
+
elsif args.size >= 2 && ["local", "cluster"].include?(args[0])
|
25
|
+
env = args.delete_at(0)
|
26
|
+
version = args.delete("--1.8") || args.delete("--1.9")
|
25
27
|
if args.size == 1
|
26
28
|
file = args[0]
|
27
29
|
load(TASKS_FILE)
|
28
|
-
Rake::Task['launch'].invoke(
|
30
|
+
Rake::Task['launch'].invoke(env, version, file)
|
29
31
|
exit
|
30
32
|
end
|
31
33
|
end
|
@@ -33,4 +35,5 @@ module RedStorm
|
|
33
35
|
usage
|
34
36
|
end
|
35
37
|
end
|
38
|
+
|
36
39
|
end
|
@@ -3,12 +3,13 @@ module RedStorm
|
|
3
3
|
class Configurator
|
4
4
|
attr_reader :config
|
5
5
|
|
6
|
-
def initialize
|
6
|
+
def initialize(defaults = {})
|
7
7
|
@config = Backtype::Config.new
|
8
|
+
defaults.each{|attribute, value| @config.put(attribute.to_s, value)}
|
8
9
|
end
|
9
10
|
|
10
11
|
def set(attribute, value)
|
11
|
-
@config.put(attribute, value)
|
12
|
+
@config.put(attribute.to_s, value)
|
12
13
|
end
|
13
14
|
|
14
15
|
def method_missing(sym, *args)
|
@@ -1,28 +1,38 @@
|
|
1
1
|
module RedStorm
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
|
3
|
+
LAUNCH_PATH = File.expand_path(File.dirname(__FILE__))
|
4
|
+
JAR_CONTEXT = !!(LAUNCH_PATH =~ /\.jar!\/red_storm$/)
|
5
5
|
|
6
6
|
if JAR_CONTEXT
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
BASE_PATH = File.expand_path(LAUNCH_PATH + '/..')
|
8
|
+
REDSTORM_HOME = BASE_PATH
|
9
|
+
TARGET_PATH = BASE_PATH
|
10
|
+
|
11
11
|
GEM_PATH = "#{TARGET_PATH}/gems/"
|
12
|
+
ENV["GEM_PATH"] = GEM_PATH
|
12
13
|
else
|
13
|
-
|
14
|
+
BASE_PATH = Dir.pwd
|
15
|
+
REDSTORM_HOME = File.expand_path(LAUNCH_PATH + '/../..')
|
14
16
|
TARGET_PATH = "#{BASE_PATH}/target"
|
15
|
-
BUNDLE_GEMFILE = "#{TARGET_PATH}/gems/bundler/Gemfile"
|
16
|
-
BUNDLE_PATH = "#{TARGET_PATH}/gems/bundler/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}/"
|
17
|
-
GEM_PATH = "#{TARGET_PATH}/gems/gems"
|
18
17
|
end
|
19
18
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
ENV['BUNDLE_DISABLE_SHARED_GEMS'] = "1"
|
19
|
+
def current_ruby_mode
|
20
|
+
RUBY_VERSION =~ /(\d+\.\d+)(\.\d+)*/
|
21
|
+
raise("unknown Ruby version #{$1}") unless $1 == "1.8" || $1 == "1.9"
|
22
|
+
$1
|
25
23
|
end
|
26
24
|
|
27
|
-
|
25
|
+
def jruby_mode_token(ruby_version = nil)
|
26
|
+
version_map = {"1.8" => "RUBY1_8", "--1.8" => "RUBY1_8", "1.9" => "RUBY1_9", "--1.9" => "RUBY1_9"}
|
27
|
+
version_map[ruby_version.to_s] || version_map[RedStorm.current_ruby_mode]
|
28
|
+
end
|
29
|
+
|
30
|
+
module_function :current_ruby_mode, :jruby_mode_token
|
31
|
+
|
32
|
+
# puts("*** LAUNCH_PATH=#{LAUNCH_PATH}")
|
33
|
+
# puts("*** JAR_CONTEXT=#{JAR_CONTEXT}")
|
34
|
+
# puts("*** BASE_PATH=#{BASE_PATH}")
|
35
|
+
# puts("*** REDSTORM_HOME=#{REDSTORM_HOME}")
|
36
|
+
# puts("*** TARGET_PATH=#{TARGET_PATH}")
|
37
|
+
# puts("*** GEM_PATH=#{GEM_PATH}") if defined?(GEM_PATH)
|
28
38
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'java'
|
1
2
|
require 'red_storm/configuration'
|
2
3
|
require 'red_storm/configurator'
|
3
4
|
|
@@ -56,6 +57,8 @@ module RedStorm
|
|
56
57
|
declarer.globalGrouping(source_id)
|
57
58
|
when :shuffle
|
58
59
|
declarer.shuffleGrouping(source_id)
|
60
|
+
when :local_or_shuffle
|
61
|
+
declarer.localOrShuffleGrouping(source_id)
|
59
62
|
when :none
|
60
63
|
declarer.noneGrouping(source_id)
|
61
64
|
when :all
|
@@ -109,28 +112,23 @@ module RedStorm
|
|
109
112
|
|
110
113
|
builder = TopologyBuilder.new
|
111
114
|
self.class.spouts.each do |spout|
|
112
|
-
declarer = builder.setSpout(spout.id, spout.new_instance(base_class_path), spout.parallelism)
|
115
|
+
declarer = builder.setSpout(spout.id, spout.new_instance(base_class_path), spout.parallelism.to_java)
|
113
116
|
declarer.addConfigurations(spout.config)
|
114
117
|
end
|
115
118
|
self.class.bolts.each do |bolt|
|
116
|
-
declarer = builder.setBolt(bolt.id, bolt.new_instance(base_class_path), bolt.parallelism)
|
119
|
+
declarer = builder.setBolt(bolt.id, bolt.new_instance(base_class_path), bolt.parallelism.to_java)
|
117
120
|
declarer.addConfigurations(bolt.config)
|
118
121
|
bolt.define_grouping(declarer)
|
119
122
|
end
|
120
123
|
|
121
|
-
|
124
|
+
# set the JRuby compatibility mode option for Storm workers, default to current JRuby mode
|
125
|
+
defaults = {"topology.worker.childopts" => "-Djruby.compat.version=#{RedStorm.jruby_mode_token}"}
|
126
|
+
|
127
|
+
configurator = Configurator.new(defaults)
|
122
128
|
configurator.instance_exec(env, &self.class.configure_block)
|
123
129
|
|
124
|
-
|
125
|
-
|
126
|
-
@cluster = LocalCluster.new
|
127
|
-
@cluster.submitTopology(self.class.topology_name, configurator.config, builder.createTopology)
|
128
|
-
when :cluster
|
129
|
-
StormSubmitter.submitTopology(self.class.topology_name, configurator.config, builder.createTopology);
|
130
|
-
else
|
131
|
-
raise("unsupported env=#{env.inspect}, expecting :local or :cluster")
|
132
|
-
end
|
133
|
-
|
130
|
+
submitter = (env == :local) ? @cluster = LocalCluster.new : StormSubmitter
|
131
|
+
submitter.submitTopology(self.class.topology_name, configurator.config, builder.createTopology)
|
134
132
|
instance_exec(env, &self.class.submit_block)
|
135
133
|
end
|
136
134
|
|
@@ -17,33 +17,12 @@ java_import 'redstorm.storm.jruby.JRubySpout'
|
|
17
17
|
|
18
18
|
java_package 'redstorm'
|
19
19
|
|
20
|
-
# setup some environment constants
|
21
|
-
# this is required here and in red_storm.rb which are both
|
22
|
-
# entry points in redstorm.
|
23
|
-
module RedStorm
|
24
|
-
LAUNCH_PATH = File.expand_path(File.dirname(__FILE__))
|
25
|
-
JAR_CONTEXT = !!(LAUNCH_PATH =~ /\.jar!$/)
|
26
|
-
|
27
|
-
if JAR_CONTEXT
|
28
|
-
BASE_PATH = LAUNCH_PATH
|
29
|
-
LIB_PATH = "#{BASE_PATH}/lib"
|
30
|
-
else
|
31
|
-
BASE_PATH = Dir.pwd
|
32
|
-
LIB_PATH = "#{BASE_PATH}/target/lib"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
20
|
# TopologyLauncher is the application entry point when launching a topology. Basically it will
|
37
21
|
# call require on the specified Ruby topology class file path and call its start method
|
38
22
|
class TopologyLauncher
|
39
23
|
|
40
24
|
java_signature 'void main(String[])'
|
41
25
|
def self.main(args)
|
42
|
-
# this is the entry point for these two contexts:
|
43
|
-
# - runnig a topology in local mode. the current Ruby env will stay the same at topology execution
|
44
|
-
# - submitting a topology in cluster mode. the current Ruby env will be valid only at topology submission. At topology execution
|
45
|
-
# in the cluster, the new entry point will be the red_storm.rb, topology_launcher will not be called
|
46
|
-
|
47
26
|
unless args.size > 1
|
48
27
|
puts("Usage: redstorm local|cluster topology_class_file_name")
|
49
28
|
exit(1)
|
@@ -52,11 +31,9 @@ class TopologyLauncher
|
|
52
31
|
env = args[0].to_sym
|
53
32
|
class_path = args[1]
|
54
33
|
|
55
|
-
|
56
|
-
$:.unshift
|
57
|
-
|
58
|
-
require 'red_storm/environment'
|
59
|
-
RedStorm.setup_gems
|
34
|
+
launch_path = Dir.pwd
|
35
|
+
$:.unshift File.expand_path(launch_path)
|
36
|
+
$:.unshift File.expand_path(launch_path + '/lib')
|
60
37
|
|
61
38
|
require "#{class_path}"
|
62
39
|
|
data/lib/red_storm/version.rb
CHANGED
data/lib/tasks/red_storm.rake
CHANGED
@@ -1,28 +1,20 @@
|
|
1
1
|
require 'ant'
|
2
|
+
require 'jruby/jrubyc'
|
3
|
+
require 'pompompom'
|
2
4
|
require 'red_storm'
|
3
|
-
|
4
|
-
# begin
|
5
|
-
# # will work from gem, since lib dir is in gem require_paths
|
6
|
-
# require 'red_storm'
|
7
|
-
# rescue LoadError
|
8
|
-
# # will work within RedStorm dev project
|
9
|
-
# $:.unshift './lib'
|
10
|
-
# require 'red_storm'
|
11
|
-
# end
|
12
5
|
|
13
|
-
INSTALL_STORM_VERSION = "0.7.
|
14
|
-
INSTALL_JRUBY_VERSION = "1.6.7"
|
15
|
-
DEFAULT_GEMFILE = "Gemfile"
|
6
|
+
INSTALL_STORM_VERSION = "0.7.3"
|
7
|
+
INSTALL_JRUBY_VERSION = "1.6.7.2"
|
16
8
|
|
17
9
|
CWD = Dir.pwd
|
18
10
|
TARGET_DIR = "#{CWD}/target"
|
19
11
|
TARGET_LIB_DIR = "#{TARGET_DIR}/lib"
|
20
12
|
TARGET_SRC_DIR = "#{TARGET_DIR}/src"
|
13
|
+
TARGET_GEM_DIR = "#{TARGET_DIR}/gems/gems"
|
14
|
+
TARGET_SPECS_DIR = "#{TARGET_DIR}/gems/specifications"
|
21
15
|
TARGET_CLASSES_DIR = "#{TARGET_DIR}/classes"
|
22
16
|
TARGET_DEPENDENCY_DIR = "#{TARGET_DIR}/dependency"
|
23
17
|
TARGET_DEPENDENCY_UNPACKED_DIR = "#{TARGET_DIR}/dependency-unpacked"
|
24
|
-
TARGET_MARKERS_DIR = "#{TARGET_DIR}/dependency-markers"
|
25
|
-
TARGET_GEMS_DIR = "#{TARGET_DIR}/gems"
|
26
18
|
TARGET_CLUSTER_JAR = "#{TARGET_DIR}/cluster-topology.jar"
|
27
19
|
|
28
20
|
REDSTORM_JAVA_SRC_DIR = "#{RedStorm::REDSTORM_HOME}/src/main"
|
@@ -31,13 +23,29 @@ REDSTORM_LIB_DIR = "#{RedStorm::REDSTORM_HOME}/lib"
|
|
31
23
|
SRC_EXAMPLES = "#{RedStorm::REDSTORM_HOME}/examples"
|
32
24
|
DST_EXAMPLES = "#{CWD}/examples"
|
33
25
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
26
|
+
module JavaZip
|
27
|
+
import 'java.util.zip.ZipFile'
|
28
|
+
end
|
29
|
+
|
30
|
+
task :launch, :env, :ruby_mode, :class_file do |t, args|
|
31
|
+
# use ruby mode parameter or default to current interpreter version
|
32
|
+
version_token = RedStorm.jruby_mode_token(args[:ruby_mode])
|
33
|
+
|
34
|
+
command = case args[:env]
|
35
|
+
when "local"
|
36
|
+
"java -Djruby.compat.version=#{version_token} -cp \"#{TARGET_CLASSES_DIR}:#{TARGET_DEPENDENCY_DIR}/*\" redstorm.TopologyLauncher local #{args[:class_file]}"
|
37
|
+
when "cluster"
|
38
|
+
unless File.exist?(TARGET_CLUSTER_JAR)
|
39
|
+
puts("cluster jar file #{TARGET_CLUSTER_JAR} not found. Generate it using $redstorm jar DIR1 [DIR2, ...]")
|
40
|
+
exit(1)
|
41
|
+
end
|
42
|
+
"storm jar #{TARGET_CLUSTER_JAR} -Djruby.compat.version=#{version_token} redstorm.TopologyLauncher cluster #{args[:class_file]}"
|
43
|
+
end
|
44
|
+
|
39
45
|
puts("launching #{command}")
|
40
|
-
system(command)
|
46
|
+
unless system(command)
|
47
|
+
puts($!)
|
48
|
+
end
|
41
49
|
end
|
42
50
|
|
43
51
|
task :clean do
|
@@ -52,45 +60,53 @@ task :setup do
|
|
52
60
|
puts("\n--> Setting up target directories")
|
53
61
|
ant.mkdir :dir => TARGET_DIR
|
54
62
|
ant.mkdir :dir => TARGET_CLASSES_DIR
|
63
|
+
ant.mkdir :dir => TARGET_DEPENDENCY_DIR
|
55
64
|
ant.mkdir :dir => TARGET_SRC_DIR
|
56
|
-
ant.mkdir :dir =>
|
57
|
-
ant.mkdir :dir =>
|
58
|
-
ant.mkdir :dir => "#{TARGET_GEMS_DIR}/bundler"
|
65
|
+
ant.mkdir :dir => TARGET_GEM_DIR
|
66
|
+
ant.mkdir :dir => TARGET_SPECS_DIR
|
59
67
|
ant.path :id => 'classpath' do
|
60
68
|
fileset :dir => TARGET_DEPENDENCY_DIR
|
61
69
|
fileset :dir => TARGET_CLASSES_DIR
|
62
70
|
end
|
63
71
|
end
|
64
72
|
|
65
|
-
task :install => [:deps, :build
|
73
|
+
task :install => [:deps, :build] do
|
66
74
|
puts("\nRedStorm install completed. All dependencies installed in #{TARGET_DIR}")
|
67
75
|
end
|
68
76
|
|
69
77
|
task :unpack do
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
78
|
+
unpack_artifacts = %w[jruby-complete]
|
79
|
+
unpack_glob = "#{TARGET_DEPENDENCY_DIR}/{#{unpack_artifacts.join(',')}}-*-jar.jar"
|
80
|
+
Dir[unpack_glob].each do |jar|
|
81
|
+
puts("Extracting #{jar}")
|
82
|
+
zf = JavaZip::ZipFile.new(jar)
|
83
|
+
zf.entries.each do |entry|
|
84
|
+
next if entry.directory?
|
85
|
+
destination = "#{TARGET_DEPENDENCY_UNPACKED_DIR}/#{entry.name}"
|
86
|
+
in_io = zf.get_input_stream(entry).to_io
|
87
|
+
FileUtils.mkdir_p(File.dirname(destination))
|
88
|
+
File.open(destination, 'w') { |out_io| out_io.write(in_io.read) }
|
89
|
+
end
|
90
|
+
end
|
76
91
|
end
|
77
92
|
|
78
93
|
task :jar, [:include_dir] => [:unpack, :clean_jar] do |t, args|
|
79
94
|
puts("\n--> Generating JAR file #{TARGET_CLUSTER_JAR}")
|
80
95
|
ant.jar :destfile => TARGET_CLUSTER_JAR do
|
81
|
-
fileset :dir => TARGET_CLASSES_DIR
|
82
96
|
fileset :dir => TARGET_DEPENDENCY_UNPACKED_DIR
|
83
|
-
fileset :dir =>
|
84
|
-
|
85
|
-
exclude :name => "bundler/.bundle/**"
|
97
|
+
fileset :dir => TARGET_DIR do
|
98
|
+
include :name => "gems/**"
|
86
99
|
end
|
100
|
+
fileset :dir => TARGET_CLASSES_DIR
|
87
101
|
# red_storm.rb and red_storm/* must be in root of jar so that "require 'red_storm'"
|
88
102
|
# in bolts/spouts works in jar context
|
89
103
|
fileset :dir => TARGET_LIB_DIR do
|
90
104
|
exclude :name => "tasks/**"
|
91
105
|
end
|
92
|
-
|
93
|
-
|
106
|
+
if args[:include_dir]
|
107
|
+
fileset :dir => CWD do
|
108
|
+
args[:include_dir].split(":").each{|dir| include :name => "#{dir}/**/*"}
|
109
|
+
end
|
94
110
|
end
|
95
111
|
manifest do
|
96
112
|
attribute :name => "Main-Class", :value => "redstorm.TopologyLauncher"
|
@@ -110,25 +126,33 @@ task :examples do
|
|
110
126
|
end
|
111
127
|
|
112
128
|
puts("\n--> Installing examples into #{DST_EXAMPLES}")
|
113
|
-
|
114
|
-
|
129
|
+
FileUtils.mkdir(DST_EXAMPLES)
|
130
|
+
FileUtils.cp_r(Dir["#{SRC_EXAMPLES}/*"], DST_EXAMPLES)
|
131
|
+
end
|
132
|
+
|
133
|
+
task :copy_red_storm do
|
134
|
+
FileUtils.cp_r(REDSTORM_LIB_DIR, TARGET_DIR)
|
115
135
|
end
|
116
136
|
|
117
137
|
task :deps => :setup do
|
118
138
|
puts("\n--> Installing dependencies")
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
139
|
+
|
140
|
+
configuration = {
|
141
|
+
:repositories => {:clojars => 'http://clojars.org/repo/', :sonatype => "http://oss.sonatype.org/content/groups/public/"},
|
142
|
+
:dependencies => [
|
143
|
+
"storm:storm:#{INSTALL_STORM_VERSION}|type_filter=jar",
|
144
|
+
"org.slf4j:slf4j-api:1.5.8|type_filter=jar",
|
145
|
+
"org.slf4j:slf4j-log4j12:1.5.8|type_filter=jar",
|
146
|
+
"org.jruby:jruby-complete:#{INSTALL_JRUBY_VERSION}|transitive=false,type_filter=jar",
|
147
|
+
],
|
148
|
+
:destination => TARGET_DEPENDENCY_DIR
|
149
|
+
}
|
150
|
+
|
151
|
+
installer = PomPomPom::Runner.new(configuration)
|
152
|
+
installer.run
|
129
153
|
end
|
130
154
|
|
131
|
-
task :build => :setup do
|
155
|
+
task :build => [:setup, :copy_red_storm] do
|
132
156
|
# compile the JRuby proxy classes to Java
|
133
157
|
build_jruby("#{REDSTORM_LIB_DIR}/red_storm/proxy")
|
134
158
|
|
@@ -145,46 +169,26 @@ task :build => :setup do
|
|
145
169
|
build_java_dir("#{TARGET_SRC_DIR}")
|
146
170
|
end
|
147
171
|
|
148
|
-
task :bundle, [:
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
if File.exist?(gemfile)
|
167
|
-
puts("\n--> Bundling gems in #{TARGET_GEMS_DIR}/bundler using #{gemfile}")
|
168
|
-
system("cp #{gemfile} #{TARGET_GEMS_DIR}/bundler/Gemfile")
|
169
|
-
cmd = "(cd #{TARGET_GEMS_DIR}/bundler; " + \
|
170
|
-
"unset BUNDLE_GEMFILE; " + \
|
171
|
-
"unset BUNDLE_PATH; " + \
|
172
|
-
"unset RUBYOPT; " + \
|
173
|
-
"export GEM_PATH=#{RedStorm::GEM_PATH}; " + \
|
174
|
-
"export GEM_HOME=#{RedStorm::GEM_PATH}; " + \
|
175
|
-
"jruby #{RedStorm::RUNTIME['RUBY_VERSION']} -S bundle install #{bundler_options})"
|
176
|
-
system(cmd)
|
177
|
-
elsif gemfile != DEFAULT_GEMFILE
|
178
|
-
puts("WARNING: #{gemfile} not found, cannot bundle gems")
|
172
|
+
task :bundle, [:groups] => :setup do |t, args|
|
173
|
+
require 'bundler'
|
174
|
+
args.with_defaults(:groups => 'default')
|
175
|
+
groups = args[:groups].split(':').map(&:to_sym)
|
176
|
+
Bundler.definition.specs_for(groups).each do |spec|
|
177
|
+
unless spec.full_name =~ /^bundler-\d+/
|
178
|
+
destination_path = "#{TARGET_GEM_DIR}/#{spec.full_name}"
|
179
|
+
unless File.directory?(destination_path)
|
180
|
+
puts("installing gem #{spec.full_name} into #{destination_path}")
|
181
|
+
# copy the actual gem dir
|
182
|
+
FileUtils.cp_r(spec.full_gem_path, destination_path)
|
183
|
+
# copy the gemspec into the specifications/ dir
|
184
|
+
FileUtils.cp_r(spec.loaded_from, TARGET_SPECS_DIR)
|
185
|
+
# strip the .git directory from git dependencies, it can be huge
|
186
|
+
FileUtils.rm_rf("#{destination_path}/.git")
|
187
|
+
end
|
188
|
+
end
|
179
189
|
end
|
180
190
|
end
|
181
191
|
|
182
|
-
task :gems => :setup do
|
183
|
-
puts("\n--> Installing base gems in #{TARGET_GEMS_DIR}/gems")
|
184
|
-
system("gem install bundler --install-dir #{TARGET_GEMS_DIR}/gems --no-ri --no-rdoc --quiet --no-verbose")
|
185
|
-
system("gem install rake --install-dir #{TARGET_GEMS_DIR}/gems --no-ri --no-rdoc --quiet --no-verbose")
|
186
|
-
end
|
187
|
-
|
188
192
|
def build_java_dir(source_folder)
|
189
193
|
puts("\n--> Compiling Java")
|
190
194
|
ant.javac(
|
@@ -204,5 +208,14 @@ end
|
|
204
208
|
|
205
209
|
def build_jruby(source_path)
|
206
210
|
puts("\n--> Compiling JRuby")
|
207
|
-
|
211
|
+
Dir.chdir(RedStorm::REDSTORM_HOME) do
|
212
|
+
argv = []
|
213
|
+
argv << '-t' << TARGET_SRC_DIR
|
214
|
+
argv << '--verbose'
|
215
|
+
argv << '--java'
|
216
|
+
argv << '-c' << %("#{TARGET_DEPENDENCY_DIR}/storm-#{INSTALL_STORM_VERSION}.jar")
|
217
|
+
argv << '-c' << %("#{TARGET_CLASSES_DIR}")
|
218
|
+
argv << source_path
|
219
|
+
status = JRuby::Compiler::compile_argv(argv)
|
220
|
+
end
|
208
221
|
end
|