rubydoop 1.1.0.pre3 → 1.1.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,6 +46,7 @@ module Rubydoop
46
46
  def create!
47
47
  create_directories!
48
48
  fetch_jruby!
49
+ find_gems!
49
50
  build_jar!
50
51
  end
51
52
 
@@ -98,54 +99,58 @@ module Rubydoop
98
99
  end
99
100
  end
100
101
 
102
+ def find_gems!
103
+ gem_specs = Bundler.definition.specs_for(@options[:gem_groups])
104
+ @options[:gem_specs] = gem_specs.select { |spec| spec.full_name !~ /^(?:bundler|rubydoop)/ }
105
+ end
106
+
101
107
  def build_jar!
102
- @tmpdir = Dir.mktmpdir('rubydoop')
103
- # the ant block is instance_exec'ed so instance variables and methods are not in scope
104
- options = @options
105
- bundled_gems = load_path
106
- lib_jars = [options[:jruby_jar_path], *options[:lib_jars]]
107
- ant :output_level => 1 do
108
- jar :destfile => options[:jar_path] do
109
- manifest { attribute :name => 'Main-Class', :value => options[:main_class] }
110
- zipfileset :src => "#{options[:rubydoop_base_dir]}/lib/rubydoop.jar"
111
- fileset :dir => "#{options[:rubydoop_base_dir]}/lib", :includes => '**/*.rb', :excludes => '*.jar'
112
- bundled_gems.each { |path| fileset :dir => path }
113
- fileset :dir => "#{options[:project_base_dir]}/lib"
114
- lib_jars.each { |extra_jar| zipfileset :dir => File.dirname(extra_jar), :includes => File.basename(extra_jar), :prefix => 'lib' }
108
+ Dir.mktmpdir('rubydoop') do |generated_files_path|
109
+ create_load_path_setup_script(generated_files_path)
110
+
111
+ # NOTE: the ant block is instance_exec'ed so instance variables and methods will not be scope
112
+
113
+ output_path = @options[:jar_path]
114
+ main_class = @options[:main_class]
115
+ project_lib = File.join(@options[:project_base_dir], 'lib')
116
+ rubydoop_jar = File.join(@options[:rubydoop_base_dir], 'lib', 'rubydoop.jar')
117
+ rubydoop_lib = File.join(@options[:rubydoop_base_dir], 'lib')
118
+ gem_specs = @options[:gem_specs]
119
+ extra_jars = [@options[:jruby_jar_path], *@options[:lib_jars]]
120
+
121
+ ant output_level: 1 do
122
+ jar destfile: output_path do
123
+ manifest { attribute name: 'Main-Class', value: main_class }
124
+
125
+ zipfileset dir: project_lib
126
+ zipfileset src: rubydoop_jar
127
+ zipfileset dir: generated_files_path
128
+ zipfileset dir: rubydoop_lib, excludes: '*.jar', prefix: "gems/rubydoop-#{Rubydoop::VERSION}/lib"
129
+
130
+ gem_specs.each do |gem_spec|
131
+ zipfileset dir: gem_spec.full_gem_path, prefix: "gems/#{File.basename(gem_spec.full_gem_path)}"
132
+ end
133
+
134
+ extra_jars.each do |extra_jar|
135
+ zipfileset dir: File.dirname(extra_jar), includes: File.basename(extra_jar), prefix: 'lib'
136
+ end
137
+ end
115
138
  end
116
139
  end
117
- ensure
118
- FileUtils.rm_rf(@tmpdir)
119
140
  end
120
141
 
121
- def load_path
122
- Bundler.definition.specs_for(@options[:gem_groups]).flat_map do |spec|
123
- if spec.full_name =~ /^jruby-openssl-\d+/
124
- Dir.chdir(@tmpdir) do
125
- repackage_openssl(spec)
142
+ def create_load_path_setup_script(base_path)
143
+ path = File.join(base_path, 'setup_load_path.rb')
144
+ FileUtils.mkdir_p(File.dirname(path))
145
+ File.open(path, 'w') do |io|
146
+ io.puts("$LOAD_PATH << 'gems/rubydoop-#{Rubydoop::VERSION}/lib'")
147
+ @options[:gem_specs].each do |gem_spec|
148
+ gem_spec.require_paths.each do |path|
149
+ relative_path = File.join(File.basename(gem_spec.full_gem_path), path)
150
+ io.puts("$LOAD_PATH << 'gems/#{relative_path}'")
126
151
  end
127
- elsif spec.full_name !~ /^(?:bundler|rubydoop)-\d+/
128
- spec.require_paths.map do |rp|
129
- "#{spec.full_gem_path}/#{rp}"
130
- end
131
- else
132
- []
133
152
  end
134
153
  end
135
154
  end
136
-
137
- def repackage_openssl(spec)
138
- FileUtils.cp_r(spec.full_gem_path, 'jruby-openssl')
139
- FileUtils.mv('jruby-openssl/lib/shared', 'jruby-openssl/new_lib')
140
- FileUtils.mv('jruby-openssl/lib/1.8', 'jruby-openssl/new_lib/openssl/1.8')
141
- FileUtils.mv('jruby-openssl/lib/1.9', 'jruby-openssl/new_lib/openssl/1.9')
142
- main_file = File.read('jruby-openssl/new_lib/openssl.rb')
143
- main_file.gsub!('../1.8', 'openssl/1.8')
144
- main_file.gsub!('../1.9', 'openssl/1.9')
145
- File.open('jruby-openssl/new_lib/openssl.rb', 'w') { |io| io.write(main_file) }
146
- FileUtils.rm_r('jruby-openssl/lib')
147
- FileUtils.mv('jruby-openssl/new_lib', 'jruby-openssl/lib')
148
- ["#{@tmpdir}/jruby-openssl/lib"]
149
- end
150
155
  end
151
156
  end
@@ -1,4 +1,4 @@
1
1
  module Rubydoop
2
2
  # @private
3
- VERSION = '1.1.0.pre3'
3
+ VERSION = '1.1.0.pre4'
4
4
  end
data/lib/rubydoop.jar CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubydoop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.pre3
4
+ version: 1.1.0.pre4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors: