ruboto 0.10.1 → 0.10.2.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/Gemfile +1 -1
  2. data/Gemfile.lock +1 -1
  3. data/Rakefile +110 -34
  4. data/assets/rakelib/ruboto.rake +181 -76
  5. data/assets/src/org/ruboto/JRubyAdapter.java +7 -3
  6. data/assets/src/org/ruboto/ScriptLoader.java +12 -4
  7. data/assets/src/ruboto/widget.rb +43 -34
  8. data/bin/ruboto +9 -4
  9. data/lib/ruboto/sdk_versions.rb +11 -2
  10. data/lib/ruboto/util/build.rb +1 -1
  11. data/lib/ruboto/util/update.rb +104 -32
  12. data/lib/ruboto/version.rb +1 -1
  13. data/test/activity/call_super_activity.rb +2 -3
  14. data/test/activity/dir_and_file_activity.rb +18 -0
  15. data/test/activity/dir_and_file_activity_test.rb +20 -0
  16. data/test/activity/image_button_and_button_activity.rb +4 -5
  17. data/test/activity/json_activity.rb +21 -0
  18. data/test/activity/json_activity_test.rb +17 -0
  19. data/test/activity/location_activity.rb +30 -0
  20. data/test/activity/location_activity_test.rb +17 -0
  21. data/test/activity/margins_activity.rb +0 -1
  22. data/test/activity/option_menu_activity.rb +0 -1
  23. data/test/activity/psych_activity.rb +8 -2
  24. data/test/activity/ssl_activity.rb +31 -0
  25. data/test/activity/ssl_activity_test.rb +22 -0
  26. data/test/activity/stack_activity.rb +0 -1
  27. data/test/activity/stack_activity_test.rb +4 -5
  28. data/test/activity/subclass_activity.rb +0 -1
  29. data/test/activity/view_constants_activity.rb +0 -1
  30. data/test/app_test_methods.rb +19 -6
  31. data/test/minimal_app_test.rb +10 -10
  32. data/test/rake_test.rb +8 -8
  33. data/test/ruboto_gen_test.rb +18 -12
  34. data/test/ruboto_update_test.rb +16 -10
  35. data/test/test_helper.rb +16 -35
  36. metadata +21 -9
@@ -322,9 +322,13 @@ public class JRubyAdapter {
322
322
 
323
323
  Thread.currentThread().setContextClassLoader(classLoader);
324
324
 
325
- String defaultCurrentDir = appContext.getFilesDir().getPath();
326
- Log.d("Setting JRuby current directory to " + defaultCurrentDir);
327
- callScriptingContainerMethod(Void.class, "setCurrentDirectory", defaultCurrentDir);
325
+ if (appContext.getFilesDir() != null) {
326
+ String defaultCurrentDir = appContext.getFilesDir().getPath();
327
+ Log.d("Setting JRuby current directory to " + defaultCurrentDir);
328
+ callScriptingContainerMethod(Void.class, "setCurrentDirectory", defaultCurrentDir);
329
+ } else {
330
+ Log.e("Unable to find app files dir!");
331
+ }
328
332
 
329
333
  if (out != null) {
330
334
  output = out;
@@ -4,6 +4,7 @@ import java.io.IOException;
4
4
 
5
5
  import android.app.ProgressDialog;
6
6
  import android.content.Context;
7
+ import android.os.Bundle;
7
8
 
8
9
  public class ScriptLoader {
9
10
  /**
@@ -106,7 +107,7 @@ public class ScriptLoader {
106
107
  }
107
108
  if (rubyClass != null) {
108
109
  if (component instanceof android.content.Context) {
109
- callOnCreate(rubyInstance, args);
110
+ callOnCreate(rubyInstance, args, component.getScriptInfo().getRubyClassName());
110
111
  }
111
112
  }
112
113
  component.getScriptInfo().setRubyInstance(rubyInstance);
@@ -119,8 +120,8 @@ public class ScriptLoader {
119
120
  }
120
121
  }
121
122
 
122
- private static final void callOnCreate(Object rubyInstance, Object[] args) {
123
- System.out.println("Call on_create on: " + rubyInstance + ", " + JRubyAdapter.get("JRUBY_VERSION"));
123
+ private static final void callOnCreate(Object rubyInstance, Object[] args, String rubyClassName) {
124
+ System.out.println("Call onCreate on: " + rubyInstance + ", " + JRubyAdapter.get("JRUBY_VERSION"));
124
125
  // FIXME(uwe): Simplify when we stop support for RubotoCore 0.4.7
125
126
  if (JRubyAdapter.isJRubyPreOneSeven()) {
126
127
  if (args.length > 0) {
@@ -129,10 +130,17 @@ public class ScriptLoader {
129
130
  JRubyAdapter.put("$ruby_instance", rubyInstance);
130
131
  JRubyAdapter.runScriptlet("$ruby_instance.on_create(" + (args.length > 0 ? "$bundle" : "") + ")");
131
132
  } else if (JRubyAdapter.isJRubyOneSeven()) {
132
- JRubyAdapter.runRubyMethod(rubyInstance, "on_create", (Object[]) args);
133
+ // FIXME(uwe): Simplify when we stop support for snake case aliasing interface callback methods.
134
+ if ((Boolean)JRubyAdapter.runScriptlet(rubyClassName + ".instance_methods(false).any?{|m| m.to_sym == :onCreate}")) {
135
+ JRubyAdapter.runRubyMethod(rubyInstance, "onCreate", args);
136
+ } else if ((Boolean)JRubyAdapter.runScriptlet(rubyClassName + ".instance_methods(false).any?{|m| m.to_sym == :on_create}")) {
137
+ JRubyAdapter.runRubyMethod(rubyInstance, "on_create", args);
138
+ }
139
+ // EMXIF
133
140
  } else {
134
141
  throw new RuntimeException("Unknown JRuby version: " + JRubyAdapter.get("JRUBY_VERSION"));
135
142
  }
143
+ // EMXIF
136
144
  }
137
145
 
138
146
  }
@@ -15,51 +15,60 @@ require 'ruboto/activity'
15
15
  # Prepare View
16
16
  #
17
17
 
18
- java_import "android.view.View"
18
+ java_import 'android.view.View'
19
+
20
+ def invoke_with_converted_arguments(target, method_name, values)
21
+ converted_values = [*values].map { |i| @@convert_constants[i] || i }
22
+ scaled_values = converted_values.map.with_index do |v, i|
23
+ v.is_a?(Integer) && v >= 0x80000000 && v <= 0xFFFFFFFF ?
24
+ v.to_i - 0x100000000 : v
25
+ end
26
+ target.send(method_name, *scaled_values)
27
+ end
19
28
 
20
29
  View.class_eval do
21
- @@convert_constants ||= {}
30
+ @@convert_constants ||= {}
22
31
 
23
- def self.add_constant_conversion(from, to)
24
- @@convert_constants[from] = to
25
- end
32
+ def self.add_constant_conversion(from, to)
33
+ @@convert_constants[from] = to
34
+ end
26
35
 
27
- def self.convert_constant(from)
28
- @@convert_constants[from] or from
36
+ def self.convert_constant(from)
37
+ @@convert_constants[from] or from
38
+ end
39
+
40
+ def self.setup_constant_conversion
41
+ (self.constants - self.superclass.constants).each do |i|
42
+ View.add_constant_conversion i.downcase.to_sym, self.const_get(i)
29
43
  end
44
+ end
30
45
 
31
- def self.setup_constant_conversion
32
- (self.constants - self.superclass.constants).each do |i|
33
- View.add_constant_conversion i.downcase.to_sym, self.const_get(i)
34
- end
46
+ def configure(context, params = {})
47
+ if width = params.delete(:width)
48
+ getLayoutParams.width = View.convert_constant(width)
35
49
  end
36
50
 
37
- def configure(context, params = {})
38
- if width = params.delete(:width)
39
- getLayoutParams.width = View.convert_constant(width)
40
- end
51
+ if height = params.delete(:height)
52
+ getLayoutParams.height = View.convert_constant(height)
53
+ end
41
54
 
42
- if height = params.delete(:height)
43
- getLayoutParams.height = View.convert_constant(height)
44
- end
45
-
46
- if margins = params.delete(:margins)
47
- getLayoutParams.set_margins(*margins)
48
- end
55
+ if margins = params.delete(:margins)
56
+ getLayoutParams.set_margins(*margins)
57
+ end
49
58
 
50
- if layout = params.delete(:layout)
51
- lp = getLayoutParams
52
- layout.each do |k, v|
53
- values = (v.is_a?(Array) ? v : [v]).map { |i| @@convert_constants[i] or i }
54
- lp.send("#{k.to_s.gsub(/_([a-z])/) { $1.upcase }}", *values)
55
- end
59
+ if layout = params.delete(:layout)
60
+ lp = getLayoutParams
61
+ layout.each do |k, v|
62
+ method_name = k.to_s.gsub(/_([a-z])/) { $1.upcase }
63
+ invoke_with_converted_arguments(lp, method_name, v)
56
64
  end
65
+ end
57
66
 
58
- params.each do |k, v|
59
- values = (v.is_a?(Array) ? v : [v]).map { |i| @@convert_constants[i] or i }
60
- self.send("set#{k.to_s.gsub(/(^|_)([a-z])/) { $2.upcase }}", *values)
61
- end
67
+ params.each do |k, v|
68
+ method_name = "set#{k.to_s.gsub(/(^|_)([a-z])/) { $2.upcase }}"
69
+ invoke_with_converted_arguments(self, method_name, v)
62
70
  end
71
+ end
63
72
  end
64
73
 
65
74
  #
@@ -96,7 +105,7 @@ def ruboto_import_widget(class_name, package_name="android.widget")
96
105
  java_import klass
97
106
  class_name = klass.java_class.name.split('.')[-1]
98
107
  end
99
-
108
+
100
109
  return unless klass
101
110
 
102
111
  RubotoActivity.class_eval "
@@ -185,7 +194,7 @@ def setup_spinner
185
194
  @adapter_list = Java::java.util.ArrayList.new
186
195
  @adapter_list.addAll(params[:list])
187
196
  item_layout = params.delete(:item_layout) || R::layout::simple_spinner_item
188
- @adapter = Java::android.widget.ArrayAdapter.new(context, item_layout, @adapter_list)
197
+ @adapter = Java::android.widget.ArrayAdapter.new(context, item_layout, @adapter_list)
189
198
  @adapter.setDropDownViewResource(params.delete(:dropdown_layout) || R::layout::simple_spinner_dropdown_item)
190
199
  setAdapter @adapter
191
200
  params.delete :list
data/bin/ruboto CHANGED
@@ -1,12 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- `android list`
3
+ output = `android list 2>&1`
4
4
  if $? != 0
5
- puts "Android SDK not in path"
5
+ puts "Android SDK not in path\n#{output}"
6
6
  exit 1
7
7
  end
8
8
 
9
- require 'ruboto/commands/base'
9
+ begin
10
+ require 'ruboto/commands/base'
11
+ rescue RuntimeError
12
+ puts $!.message
13
+ exit 1
14
+ end
10
15
 
11
16
  # Run Base, which will handle actual commands
12
- Ruboto::Commands::Base.main
17
+ Ruboto::Commands::Base.main
@@ -9,9 +9,18 @@ module Ruboto
9
9
  if ENV['ANDROID_HOME']
10
10
  ANDROID_HOME = ENV['ANDROID_HOME']
11
11
  else
12
- adb_location = `#{RUBY_PLATFORM =~ /mingw|mswin/ ? "where" : "which"} adb`.chomp
13
- raise 'Unable to locate ANDROID_HOME. Either set the ANDROID_HOME environment variable or add the location of the "adb" command to your path.' if adb_location.empty?
12
+ adb_location = `#{RUBY_PLATFORM =~ /mingw|mswin/ ? 'where' : 'which'} adb`.chomp
13
+ if adb_location.empty?
14
+ raise 'Unable to locate the "adb" command. Either set the ANDROID_HOME environment variable or add the location of the "adb" command to your path.'
15
+ end
14
16
  ANDROID_HOME = File.dirname(File.dirname(Pathname.new(adb_location).realpath))
17
+ unless File.exists? "#{ANDROID_HOME}/tools"
18
+ puts "Found '#{adb_location}' but it is not in a proper Android SDK installation."
19
+ end
20
+ end
21
+ unless File.exists? "#{ANDROID_HOME}/tools"
22
+ raise "The '<ANDROID_HOME>/tools' directory is missing.
23
+ Please set the ANDROID_HOME environment variable to a proper Android SDK installation."
15
24
  end
16
25
  ANDROID_TOOLS_REVISION = File.read("#{ANDROID_HOME}/tools/source.properties").slice(/Pkg.Revision=\d+/).slice(/\d+$/).to_i
17
26
  end
@@ -56,7 +56,7 @@ module Ruboto
56
56
 
57
57
  # Remove methods changed outside of the scope of the sdk versions
58
58
  methods = methods.select{|i| !i.attribute('api_added') || (i.attribute('api_added').to_i <= target_api)}
59
- methods = methods.select{|i| !i.attribute('deprecated') || (i.attribute('deprecated').to_i > min_api)}
59
+ # methods = methods.select{|i| !i.attribute('deprecated') || (i.attribute('deprecated').to_i > min_api)}
60
60
  methods = methods.select{|i| !i.attribute('api_removed') || (i.attribute('api_removed').to_i > min_api)}
61
61
 
62
62
  # Inform and remove methods that do not exist in one of the sdk versions
@@ -161,10 +161,14 @@ module Ruboto
161
161
  log_action("Copying #{JRubyJars::core_jar_path} to libs") { copier.copy_from_absolute_path JRubyJars::core_jar_path, "libs" }
162
162
  log_action("Copying #{JRubyJars::stdlib_jar_path} to libs") { copier.copy_from_absolute_path JRubyJars::stdlib_jar_path, "libs" }
163
163
 
164
- log_action("Copying dx.jar to libs") do
164
+ unless File.read('project.properties') =~ /^dex.force.jumbo=/
165
+ log_action('Setting JUMBO dex file format') do
166
+ File.open('project.properties', 'a') { |f| f << "dex.force.jumbo=true\n" }
167
+ end
168
+ end
169
+
170
+ log_action('Copying dx.jar to libs') do
165
171
  copier.copy 'libs'
166
- # FIXME(uwe): We may need this for newer Android SDK versions. Keeping as reminder.
167
- # File.open('project.properties', 'a'){|f| f << "dex.force.jumbo=true\n"}
168
172
  end
169
173
 
170
174
  reconfigure_jruby_libs(new_jruby_version)
@@ -357,7 +361,7 @@ module Ruboto
357
361
  `jar -xf #{jruby_core}`
358
362
  raise "Unpacking jruby-core jar failed: #$?" unless $? == 0
359
363
  File.delete jruby_core
360
- if Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.2.dev')
364
+ if Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.3.dev')
361
365
  excluded_core_packages = [
362
366
  '**/*Darwin*',
363
367
  '**/*Ruby20*',
@@ -376,6 +380,7 @@ module Ruboto
376
380
  'jnr/ffi/types',
377
381
  'jnr/posix/MacOS*',
378
382
  'jnr/posix/OpenBSD*',
383
+ 'jnr/x86asm',
379
384
  'org/apache',
380
385
  'org/fusesource',
381
386
  'org/jruby/ant',
@@ -390,16 +395,43 @@ module Ruboto
390
395
  # 'org/jruby/ext/ffi', # Used by several JRuby core classes, but should not be needed unless we add FFI support
391
396
  'org/jruby/ext/ffi/io',
392
397
  'org/jruby/ext/ffi/jffi',
393
- 'org/jruby/ext/openssl', # TODO(uwe): Issue #154 Add back when we add jruby-openssl.
394
398
  'org/jruby/javasupport/bsf',
395
-
396
399
  # 'org/jruby/management', # should be excluded
397
-
398
- 'org/jruby/org/bouncycastle', # TODO(uwe): Issue #154 Add back when we add jruby-openssl. The bouncycastle included in Android is cripled.
399
-
400
400
  # 'org/jruby/runtime/invokedynamic', # Should be excluded
401
401
  ]
402
- elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.1.dev')
402
+ elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.2')
403
+ excluded_core_packages = [
404
+ '**/*Darwin*',
405
+ '**/*Ruby20*',
406
+ '**/*Solaris*',
407
+ '**/*windows*',
408
+ '**/*Windows*',
409
+ 'META-INF',
410
+ 'com/headius',
411
+ 'com/kenai/constantine', 'com/kenai/jffi', 'com/martiansoftware',
412
+ 'jline', 'jni',
413
+ 'jnr/constants/platform/darwin', 'jnr/constants/platform/fake', 'jnr/constants/platform/freebsd',
414
+ 'jnr/constants/platform/openbsd', 'jnr/constants/platform/sunos',
415
+ 'jnr/ffi/annotations', 'jnr/ffi/byref',
416
+ 'jnr/ffi/provider', 'jnr/ffi/util',
417
+ 'jnr/ffi/Struct$*',
418
+ 'jnr/ffi/types',
419
+ 'jnr/posix/MacOS*',
420
+ 'jnr/posix/OpenBSD*',
421
+ 'org/apache',
422
+ 'org/fusesource',
423
+ 'org/jruby/ant',
424
+ 'org/jruby/cext',
425
+ 'org/jruby/compiler/util',
426
+ 'org/jruby/demo',
427
+ 'org/jruby/embed/bsf',
428
+ 'org/jruby/embed/jsr223',
429
+ 'org/jruby/embed/osgi',
430
+ 'org/jruby/ext/ffi/io',
431
+ 'org/jruby/ext/ffi/jffi',
432
+ 'org/jruby/javasupport/bsf',
433
+ ]
434
+ elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.1')
403
435
  excluded_core_packages = [
404
436
  '**/*Darwin*',
405
437
  '**/*Ruby20*',
@@ -422,24 +454,16 @@ module Ruboto
422
454
  'org/fusesource',
423
455
  'org/jruby/ant',
424
456
  'org/jruby/cext',
425
- # 'org/jruby/compiler', # Needed for initialization, but shoud not be necessary
426
- # 'org/jruby/compiler/impl', # Needed for initialization, but shoud not be necessary
427
457
  'org/jruby/compiler/util',
428
458
  'org/jruby/demo',
429
459
  'org/jruby/embed/bsf',
430
460
  'org/jruby/embed/jsr223',
431
461
  'org/jruby/embed/osgi',
432
- # 'org/jruby/ext/ffi', # Used by several JRuby core classes, but should not be needed unless we add FFI support
433
462
  'org/jruby/ext/ffi/io',
434
463
  'org/jruby/ext/ffi/jffi',
435
464
  'org/jruby/ext/openssl', # TODO(uwe): Issue #154 Add back when we add jruby-openssl.
436
465
  'org/jruby/javasupport/bsf',
437
-
438
- # 'org/jruby/management', # should be excluded
439
-
440
466
  'org/jruby/org/bouncycastle', # TODO(uwe): Issue #154 Add back when we add jruby-openssl. The bouncycastle included in Android is cripled.
441
-
442
- # 'org/jruby/runtime/invokedynamic', # Should be excluded
443
467
  ]
444
468
  elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.0')
445
469
  # TODO(uwe): Remove when we stop supporting jruby-jars 1.7.0
@@ -476,7 +500,7 @@ module Ruboto
476
500
  'org/jruby/javasupport/bsf',
477
501
  ]
478
502
  # ODOT
479
- elsif Gem::Version.new(jruby_core_version) =~ Gem::Version.new('~>1.6.0')
503
+ elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.6.0')
480
504
  # TODO(uwe): Remove when we stop supporting jruby-jars 1.6.x
481
505
  print 'Retaining com.kenai.constantine and removing jnr for JRuby 1.6.x...'
482
506
  excluded_core_packages = [
@@ -504,7 +528,7 @@ module Ruboto
504
528
  if File.directory? i
505
529
  FileUtils.remove_dir(i, true) rescue puts "Failed to remove package: #{i} (#{$!})"
506
530
  elsif Dir[i].each { |f| FileUtils.rm_rf f }.empty?
507
- puts "Exclude pattern #{i.inspect} found no files."
531
+ print "exclude pattern #{i.inspect} found no files..."
508
532
  end
509
533
  end
510
534
 
@@ -542,6 +566,7 @@ module Ruboto
542
566
 
543
567
  # - Moves ruby stdlib to the root of the jruby-stdlib jar
544
568
  def reconfigure_jruby_stdlib
569
+ min_sdk_version = verify_manifest.elements['uses-sdk'].attributes["android:minSdkVersion"].to_i
545
570
  excluded_stdlibs = [*verify_ruboto_config[:excluded_stdlibs]].compact
546
571
  Dir.chdir 'libs' do
547
572
  jruby_stdlib = JRubyJars::stdlib_jar_path.split('/')[-1]
@@ -557,12 +582,13 @@ module Ruboto
557
582
  FileUtils.move 'old/META-INF/jruby.home/lib', 'new/jruby.home/lib'
558
583
  FileUtils.rm_rf 'new/jruby.home/lib/ruby/gems'
559
584
 
585
+ raise "Unrecognized JRuby stdlib jar: #{jruby_stdlib}" unless jruby_stdlib =~ /jruby-stdlib-(.*).jar/
586
+ jruby_stdlib_version = Gem::Version.new($1)
587
+
560
588
  if excluded_stdlibs.any?
561
589
 
562
590
  # TODO(uwe): Simplify when we stop supporting JRuby < 1.7.0
563
- raise "Unrecognized JRuby stdlib jar: #{jruby_stdlib}" unless jruby_stdlib =~ /jruby-stdlib-(.*).jar/
564
- jruby_version = Gem::Version.new($1)
565
- if Gem::Requirement.new('< 1.7.0.preview1') =~ jruby_version
591
+ if jruby_stdlib_version < Gem::Version.new('1.7.0.preview1')
566
592
  lib_dirs = ['1.8', '1.9', 'site_ruby/1.8', 'site_ruby/1.9', 'site_ruby/shared']
567
593
  else
568
594
  lib_dirs = ['1.8', '1.9', 'shared']
@@ -580,14 +606,60 @@ module Ruboto
580
606
  print "excluded #{excluded_stdlibs.join(' ')}..."
581
607
  end
582
608
 
583
- Dir.chdir "new" do
584
- # Uncomment this part to split the stdlib into one jar per directory
585
- # Dir['jruby.home/lib/ruby/*/*'].select { |f| File.directory? f }.each do |d|
586
- # file = "#{d}.rb"
587
- # `jar -cf ../../jruby-stdlib-#{d.gsub('/', '-')}-#{JRubyJars::VERSION}.jar #{d} #{file if File.exists?(file)}`
588
- # FileUtils.rm_rf d
589
- # FileUtils.rm_rf file if File.exists?(file)
590
- # end
609
+ Dir.chdir 'new' do
610
+ Dir['**/*.jar'].each do |j|
611
+
612
+ # FIXME(uwe): Installing bcmail-jdk15-146.jar + bcprov-jdk15-146.jar fails due to
613
+ # http://code.google.com/p/android/issues/detail?id=40409
614
+ # This breaks ssl and https. Remove when we stop supporting JRuby <= 1.7.2
615
+ if j =~ /bcmail|bcprov-jdk15-146/
616
+ FileUtils.rm j
617
+ next
618
+ end
619
+ # EMXIF
620
+
621
+ # FIXME(uwe): Adding the jars triggers the "LinearAlloc exceeded capacity"
622
+ # bug in Android 2.3. Remove when we stop supporting android-10 and older
623
+ if min_sdk_version <= 10
624
+ FileUtils.rm j
625
+ next
626
+ end
627
+ # EMXIF
628
+
629
+ # FIXME(uwe): These should be included but break the 64K method count limit
630
+ if j =~ /bcpkix-jdk15on-147|bcprov-jdk15on-147|jopenssl|kryptcore|kryptproviderjdk/
631
+ FileUtils.rm j
632
+ next
633
+ end
634
+ # EMXIF
635
+
636
+ print "#{File.basename(j).chomp('.jar')}..."
637
+ system "jar xf #{j}"
638
+ FileUtils.rm j
639
+
640
+ if j =~ %r{json/ext/generator.jar$}
641
+ jar_load_code = <<-END_CODE
642
+ require 'jruby'
643
+ puts 'Starting JSON Generator Service'
644
+ public
645
+ Java::json.ext.GeneratorService.new.basicLoad(JRuby.runtime)
646
+ END_CODE
647
+ elsif j =~ %r{json/ext/parser.jar$}
648
+ jar_load_code = <<-END_CODE
649
+ require 'jruby'
650
+ puts 'Starting JSON Parser Service'
651
+ public
652
+ Java::json.ext.ParserService.new.basicLoad(JRuby.runtime)
653
+ END_CODE
654
+ else
655
+ jar_load_code = ''
656
+ end
657
+
658
+ File.open("#{j}.rb", 'w'){|f| f << jar_load_code}
659
+ File.open("#{j}.jar.rb", 'w'){|f| f << jar_load_code}
660
+ #FileUtils.rm Dir['**/*$POPULATOR.class']
661
+ #FileUtils.rm Dir['**/*$INVOKER$*.class']
662
+ end
591
663
 
592
664
  `jar -cf ../../#{jruby_stdlib} .`
593
665
  raise "Creating repackaged jruby-stdlib jar failed: #$?" unless $? == 0
@@ -595,7 +667,7 @@ module Ruboto
595
667
  end
596
668
  end
597
669
 
598
- FileUtils.remove_dir "tmp", true
670
+ FileUtils.remove_dir 'tmp', true
599
671
  end
600
672
  end
601
673