/
java_package.rb
47 lines (35 loc) · 1.01 KB
/
java_package.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require_relative 'features/java'
module IronWorkerNG
class JavaPackage < IronWorkerNG::Package
include IronWorkerNG::Features::Java::InstanceMethods
def initialize(worker_path = nil, worker_klass = nil)
merge_worker(worker_path, worker_klass) if (not worker_path.nil?) && (not worker_klass.nil?)
end
def create_runner(zip)
classpath_array = []
@features.each do |f|
if f.respond_to?(:code_for_classpath)
classpath_array << f.send(:code_for_classpath)
end
end
classpath = classpath_array.join(':')
zip.get_output_stream('runner.rb') do |runner|
runner.write <<RUNNER
# IronWorker NG #{File.read(File.dirname(__FILE__) + '/../../VERSION').gsub("\n", '')}
root = nil
($*.size - 2).downto(0) do |i|
root = $*[i + 1] if $*[i] == '-d'
end
Dir.chdir(root)
puts `java -cp #{classpath} #{worker.klass} \#{$*.join(' ')}`
RUNNER
end
end
def runtime
'ruby'
end
def runner
'runner.rb'
end
end
end