test/test_helper.rb in ruboto-1.0.3 vs test/test_helper.rb in ruboto-1.1.0
- old
+ new
@@ -90,11 +90,11 @@
RUBOTO_PLATFORM = ENV['RUBOTO_PLATFORM'] || 'CURRENT'
puts "RUBOTO_PLATFORM: #{RUBOTO_PLATFORM}"
if RUBOTO_PLATFORM == 'CURRENT'
- JRUBY_JARS_VERSION = Gem::Version.new('1.7.4')
+ JRUBY_JARS_VERSION = Gem::Version.new('1.7.12')
elsif ENV['JRUBY_JARS_VERSION']
JRUBY_JARS_VERSION = Gem::Version.new(ENV['JRUBY_JARS_VERSION'])
else
# FIXME(uwe): Simplify when we stop supporting rubygems < 1.8.0
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0')
@@ -157,26 +157,29 @@
heap_alloc = options.delete(:heap_alloc)
included_stdlibs = options.delete(:included_stdlibs)
package = options.delete(:package) || PACKAGE
standalone = options.delete(:standalone) || !!included_stdlibs || !!excluded_stdlibs || ENV['RUBOTO_PLATFORM'] == 'STANDALONE'
update = options.delete(:update) || false
- ruby_version = options.delete(:ruby_version) || (JRUBY_JARS_VERSION.to_s[0..0] == "9" ? 2.1 : 1.9)
- raise "Unknown options: #{options.inspect}" unless options.empty?
+ ruby_version = options.delete(:ruby_version) || (JRUBY_JARS_VERSION.to_s[0..0] == '9' ? 2.1 : 1.9)
+ multi_dex = options.has_key?(:multi_dex) ? options.delete(:multi_dex) :
+ (standalone && !example && ANDROID_TARGET >= 16)
+ raise "Unknown options: #{options.inspect}" unless options.empty?
raise 'Inclusion/exclusion of libs requires standalone mode.' if (included_stdlibs || excluded_stdlibs) && !standalone
Dir.mkdir TMP_DIR unless File.exists? TMP_DIR
FileUtils.rm_rf APP_DIR if File.exists? APP_DIR
template_dir = "#{APP_DIR}_template_#{$$}"
template_dir << "_package_#{package}" if package != PACKAGE
template_dir << "_heap_alloc_#{heap_alloc}" if heap_alloc
-# template_dir << "_ruby_version_#{ruby_version.to_s.gsub('.', '_')}" if ruby_version
+ # template_dir << "_ruby_version_#{ruby_version.to_s.gsub('.', '_')}" if ruby_version
template_dir << "_example_#{example}" if example
template_dir << "_bundle_#{[*bundle].join('_')}" if bundle
template_dir << '_updated' if update
template_dir << '_standalone' if standalone
+ template_dir << '_multi-dex' if multi_dex
template_dir << "_without_#{excluded_stdlibs.map { |ed| ed.gsub(/[.\/]/, '_') }.join('_')}" if excluded_stdlibs
template_dir << "_with_#{included_stdlibs.map { |ed| ed.gsub(/[.\/]/, '_') }.join('_')}" if included_stdlibs
if File.exists?(template_dir)
puts "Copying app from template #{template_dir}"
FileUtils.cp_r template_dir, APP_DIR, :preserve => true
@@ -187,11 +190,13 @@
end
Dir.chdir APP_DIR do
File.open('local.properties', 'w') { |f| f.puts "sdk.dir=#{ANDROID_HOME}" }
File.open('test/local.properties', 'w') { |f| f.puts "sdk.dir=#{ANDROID_HOME}" }
if standalone
- write_ruboto_yml(included_stdlibs, excluded_stdlibs, heap_alloc, ruby_version) if included_stdlibs || excluded_stdlibs || heap_alloc || ruby_version
+ if included_stdlibs || excluded_stdlibs || heap_alloc || ruby_version || multi_dex
+ write_ruboto_yml(included_stdlibs, excluded_stdlibs, heap_alloc, ruby_version, multi_dex)
+ end
FileUtils.touch 'libs/jruby-core-x.x.x.jar'
FileUtils.touch 'libs/jruby-stdlib-x.x.x.jar'
install_jruby_jars_gem
else
FileUtils.rm(Dir['libs/{jruby-*.jar,dx.jar}'])
@@ -209,29 +214,26 @@
FileUtils.rm_rf APP_DIR
raise "gen app failed with return code #$?"
end
Dir.chdir APP_DIR do
write_gemfile(bundle) if bundle
- write_ruboto_yml(included_stdlibs, excluded_stdlibs, heap_alloc, ruby_version) if included_stdlibs || excluded_stdlibs || heap_alloc || ruby_version
+ if included_stdlibs || excluded_stdlibs || heap_alloc || ruby_version || multi_dex
+ sleep 1
+ write_ruboto_yml(included_stdlibs, excluded_stdlibs, heap_alloc, ruby_version, multi_dex)
+ system 'rake build_xml jruby_adapter'
+ end
if standalone
system "#{RUBOTO_CMD} gen jruby"
raise "update jruby failed with return code #$?" if $? != 0
end
end
end
- # FIXME(uwe): Installation with dx.jar fails on Android < 4.0.3 due to complex interface structure
- # Fixme(uwe): Remove when solved
- #if standalone && ANDROID_OS < 15
- # Dir.chdir APP_DIR do
- # puts "Removing dx.jar for android-#{ANDROID_OS}"
- # FileUtils.rm(Dir['libs/dx.jar'])
- # end
- #end
- # EMXIF
-
Dir.chdir APP_DIR do
+ File.write('AndroidManifest.xml',
+ File.read('AndroidManifest.xml').sub(%r{</manifest>},
+ " <uses-permission android:name='android.permission.INTERNET'/>\n</manifest>"))
if update
update_app
end
if update || !example
system 'rake patch_dex' # Ensure dx heap space is sufficient.
@@ -287,24 +289,26 @@
FileUtils.rm_rf 'tmp/RubotoCore'
fail 'Error (un)installing RubotoCore'
end
end
- def write_ruboto_yml(included_stdlibs, excluded_stdlibs, heap_alloc, ruby_version)
+ def write_ruboto_yml(included_stdlibs, excluded_stdlibs, heap_alloc, ruby_version, multi_dex)
yml = YAML.dump({'included_stdlibs' => included_stdlibs,
- 'excluded_stdlibs' => excluded_stdlibs,
- # 'ruby_version' => ruby_version,
- 'heap_alloc' => heap_alloc})
+ 'excluded_stdlibs' => excluded_stdlibs,
+ # 'ruby_version' => ruby_version,
+ 'heap_alloc' => heap_alloc,
+ 'multi_dex' => multi_dex,
+ })
puts "Adding ruboto.yml:\n#{yml}"
File.open('ruboto.yml', 'w') { |f| f << yml }
end
def write_gemfile(bundle)
gems = [*bundle]
puts "Adding Gemfile.apk: #{gems.join(' ')}"
File.open('Gemfile.apk', 'w') do |f|
f << "source 'http://rubygems.org/'\n\n"
- gems.each { |g| f << "gem #{[*g].map{|gp|"'#{gp}'"}.join(', ')}\n" }
+ gems.each { |g| f << "gem #{[*g].map { |gp| "'#{gp}'" }.join(', ')}\n" }
end
end
end