lib/ruboto/util/update.rb in ruboto-0.13.0 vs lib/ruboto/util/update.rb in ruboto-0.14.0

- old
+ new

@@ -126,15 +126,15 @@ File.open('build.xml', 'w') { |f| f << ant_script } end end def update_jruby(force=nil, explicit = false) - jruby_core = Dir.glob('libs/jruby-core-*.jar')[0] - jruby_stdlib = Dir.glob('libs/jruby-stdlib-*.jar')[0] + installed_jruby_core = Dir.glob('libs/jruby-core-*.jar')[0] + installed_jruby_stdlib = Dir.glob('libs/jruby-stdlib-*.jar')[0] unless force - if !jruby_core || !jruby_stdlib + if !installed_jruby_core || !installed_jruby_stdlib puts "Cannot find existing jruby jars in libs. Make sure you're in the root directory of your app." if explicit return false end end @@ -145,25 +145,25 @@ return false end new_jruby_version = JRubyJars::VERSION unless force - current_jruby_version = jruby_core ? jruby_core[16..-5] : 'None' + current_jruby_version = installed_jruby_core ? installed_jruby_core[16..-5] : 'None' if current_jruby_version == new_jruby_version puts "JRuby is up to date at version #{new_jruby_version}. Make sure you 'gem update jruby-jars' if there is a new version." return false end puts "Current jruby version: #{current_jruby_version}" puts "New jruby version: #{new_jruby_version}" end copier = AssetCopier.new Ruboto::ASSETS, File.expand_path('.') - log_action("Removing #{jruby_core}") { File.delete *Dir.glob('libs/jruby-core-*.jar') } if jruby_core - log_action("Removing #{jruby_stdlib}") { File.delete *Dir.glob('libs/jruby-stdlib-*.jar') } if jruby_stdlib - log_action("Copying #{JRubyJars::core_jar_path} to libs") { copier.copy_from_absolute_path JRubyJars::core_jar_path, 'libs' } - log_action("Copying #{JRubyJars::stdlib_jar_path} to libs") { copier.copy_from_absolute_path JRubyJars::stdlib_jar_path, 'libs' } + log_action("Removing #{installed_jruby_core}") { File.delete *Dir.glob('libs/jruby-core-*.jar') } if installed_jruby_core + log_action("Removing #{installed_jruby_stdlib}") { File.delete *Dir.glob('libs/jruby-stdlib-*.jar') } if installed_jruby_stdlib + log_action("Copying #{JRubyJars::core_jar_path} to libs") { FileUtils.cp JRubyJars::core_jar_path, "libs/jruby-core-#{new_jruby_version}.jar" } + log_action("Copying #{JRubyJars::stdlib_jar_path} to libs") { FileUtils.cp JRubyJars::stdlib_jar_path, "libs/jruby-stdlib-#{new_jruby_version}.jar" } unless File.read('project.properties') =~ /^dex.force.jumbo=/ log_action('Setting JUMBO dex file format') do File.open('project.properties', 'a') { |f| f << "dex.force.jumbo=true\n" } end @@ -299,10 +299,14 @@ unless app_element.elements["activity[@android:name='org.ruboto.RubotoActivity']"] app_element.add_element 'activity', {'android:name' => 'org.ruboto.RubotoActivity', 'android:exported' => 'false'} end + unless app_element.elements["activity[@android:name='org.ruboto.SplashActivity']"] + app_element.add_element 'activity', {'android:name' => 'org.ruboto.SplashActivity', 'android:exported' => 'false', 'android:configChanges' => (target.to_i >= 13 ? 'orientation|screenSize' : 'orientation')} + end + unless app_element.elements["activity[@android:name='org.ruboto.RubotoDialog']"] app_element.add_element 'activity', {'android:name' => 'org.ruboto.RubotoDialog', 'android:exported' => 'false', 'android:theme' => '@android:style/Theme.Dialog'} end unless app_element.elements["service[@android:name='org.ruboto.RubotoService']"] @@ -327,21 +331,33 @@ version_file = File.expand_path("./#{SCRIPTS_DIR}/ruboto/version.rb") File.read(version_file).slice(/^\s*VERSION = '(.*?)'/, 1) if File.exists?(version_file) end def update_ruboto(force=nil) + source_files_pattern = 'ruboto{.rb,/**/*}' + new_sources_dir = Ruboto::GEM_ROOT + "/assets/#{SCRIPTS_DIR}" + new_sources = Dir.chdir(new_sources_dir) { Dir[source_files_pattern] }. + select { |f| !(File.directory?("#{new_sources_dir}/#{f}") || File.basename(f) == '.' || File.basename(f) == '..') } + old_sources = Dir.chdir("#{SCRIPTS_DIR}") { Dir[source_files_pattern] }. + select { |f| !(File.directory?("#{SCRIPTS_DIR}/#{f}") || File.basename(f) == '.' || File.basename(f) == '..') } + obsolete_sources = old_sources - new_sources - %w(ruboto/version.rb) + obsolete_sources.each do |f| + log_action("Deleting obsolete script #{f}") do + FileUtils.rm_f f + end + end log_action('Copying ruboto/version.rb') do from = File.expand_path(Ruboto::GEM_ROOT + '/lib/ruboto/version.rb') to = File.expand_path("./#{SCRIPTS_DIR}/ruboto/version.rb") FileUtils.mkdir_p File.dirname(to) FileUtils.cp from, to end log_action('Copying additional ruboto script components') do - Dir.glob(Ruboto::GEM_ROOT + "/assets/#{SCRIPTS_DIR}/ruboto/**/*.rb").each do |from| - to = File.expand_path("./#{from.slice /#{SCRIPTS_DIR}\/ruboto\/.*\.rb/}") + new_sources.each do |from| + to = File.expand_path(from, SCRIPTS_DIR) FileUtils.mkdir_p File.dirname(to) - FileUtils.cp from, to + FileUtils.cp "#{new_sources_dir}/#{from}", to end end end def reconfigure_jruby_libs(jruby_core_version) @@ -351,21 +367,21 @@ end # - Removes unneeded code from jruby-core # - Split into smaller jars that can be used separately def reconfigure_jruby_core(jruby_core_version) - jruby_core = JRubyJars::core_jar_path.split('/')[-1] Dir.chdir 'libs' do + jruby_core = Dir['jruby-core-*.jar'][-1] log_action("Removing unneeded classes from #{jruby_core}") do FileUtils.rm_rf 'tmp' Dir.mkdir 'tmp' Dir.chdir 'tmp' do FileUtils.move "../#{jruby_core}", '.' `jar -xf #{jruby_core}` raise "Unpacking jruby-core jar failed: #$?" unless $? == 0 File.delete jruby_core - if Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.4.dev') + if Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.5.dev') #noinspection RubyLiteralArrayInspection excluded_core_packages = [ '**/*Darwin*', '**/*Solaris*', '**/*windows*', @@ -374,11 +390,11 @@ 'com/headius', 'com/kenai/constantine', 'com/kenai/jffi', 'com/kenai/jnr/x86asm', 'com/martiansoftware', - 'jline', 'jni', + 'jni', 'jnr/constants/platform/darwin', 'jnr/constants/platform/fake', 'jnr/constants/platform/freebsd', 'jnr/constants/platform/openbsd', 'jnr/constants/platform/sunos', @@ -392,12 +408,10 @@ 'jnr/posix/Aix*', 'jnr/posix/FreeBSD*', 'jnr/posix/MacOS*', 'jnr/posix/OpenBSD*', 'jnr/x86asm', - 'org/apache', - 'org/fusesource', 'org/jruby/ant', 'org/jruby/cext', # 'org/jruby/compiler', # Needed for initialization, but should not be necessary # 'org/jruby/compiler/impl', # Needed for initialization, but should not be necessary 'org/jruby/compiler/impl/BaseBodyCompiler*', @@ -408,24 +422,20 @@ 'org/jruby/embed/osgi', # 'org/jruby/ext/ffi', # Used by several JRuby core classes, but should not be needed unless we add FFI support 'org/jruby/ext/ffi/AbstractMemory*', 'org/jruby/ext/ffi/io', 'org/jruby/ext/ffi/jffi', - 'org/jruby/ext/ripper', 'org/jruby/ext/tracepoint', - #'org/jruby/ir/dataflow', - #'org/jruby/ir/dataflow/analyses', - #'org/jruby/ir/representations', - #'org/jruby/ir/runtime', - #'org/jruby/ir/targets', - #'org/jruby/ir/transformations', - #'org/jruby/ir/util', 'org/jruby/javasupport/bsf', # 'org/jruby/management', # should be excluded # 'org/jruby/runtime/invokedynamic', # Should be excluded + # 'org/jruby/runtime/opto', # What is this? + # 'org/jruby/runtime/opto/OptoFactory*', # What is this? 'org/yecht', ] + elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.4') + excluded_core_packages = %w(**/*Darwin* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi com/kenai/jnr/x86asm com/martiansoftware jline jni jnr/constants/platform/darwin jnr/constants/platform/fake jnr/constants/platform/freebsd jnr/constants/platform/openbsd jnr/constants/platform/sunos jnr/ffi/annotations jnr/ffi/byref jnr/ffi/mapper jnr/ffi/provider jnr/ffi/util jnr/ffi/Struct$* jnr/ffi/types jnr/posix/Aix* jnr/posix/FreeBSD* jnr/posix/MacOS* jnr/posix/OpenBSD* jnr/x86asm org/apache org/fusesource org/jruby/ant org/jruby/cext org/jruby/compiler/impl/BaseBodyCompiler* org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/AbstractMemory* org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/ext/ripper org/jruby/ext/tracepoint org/jruby/javasupport/bsf org/yecht) elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.3') excluded_core_packages = %w(**/*Darwin* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi com/kenai/jnr/x86asm com/martiansoftware jline jni jnr/constants/platform/darwin jnr/constants/platform/fake jnr/constants/platform/freebsd jnr/constants/platform/openbsd jnr/constants/platform/sunos jnr/ffi/annotations jnr/ffi/byref jnr/ffi/provider jnr/ffi/util jnr/ffi/Struct$* jnr/ffi/types jnr/posix/FreeBSD* jnr/posix/MacOS* jnr/posix/OpenBSD* jnr/x86asm org/apache org/fusesource org/jruby/ant org/jruby/cext org/jruby/compiler/impl/BaseBodyCompiler* org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/AbstractMemory* org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/javasupport/bsf org/yecht) elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.2') excluded_core_packages = %w(**/*Darwin* **/*Ruby20* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi com/martiansoftware jline jni jnr/constants/platform/darwin jnr/constants/platform/fake jnr/constants/platform/freebsd jnr/constants/platform/openbsd jnr/constants/platform/sunos jnr/ffi/annotations jnr/ffi/byref jnr/ffi/provider jnr/ffi/util jnr/ffi/Struct$* jnr/ffi/types jnr/posix/MacOS* jnr/posix/OpenBSD* org/apache org/fusesource org/jruby/ant org/jruby/cext org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/javasupport/bsf) elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.1') @@ -467,11 +477,11 @@ # `jar -cf ../jruby-core-#{dir.gsub('/', '.')}-#{jruby_core_version}.jar #{dir}` # FileUtils.rm_rf dir #end # Add our proxy class factory - android_jar = Dir["#{ANDROID_HOME}/platforms/*/android.jar"][0] + android_jar = Dir["#{ANDROID_HOME.gsub("\\", "/")}/platforms/*/android.jar"][0] unless android_jar puts puts '*' * 80 puts " Could not find any Android platforms in #{ANDROID_HOME}/platforms." puts ' At least one Android Platform SDK must be installed to compile the Ruboto classes.' @@ -498,11 +508,11 @@ def reconfigure_jruby_stdlib min_sdk_version = verify_manifest.elements['uses-sdk'].attributes['android:minSdkVersion'].to_i included_stdlibs = verify_ruboto_config[:included_stdlibs] excluded_stdlibs = [*verify_ruboto_config[:excluded_stdlibs]].compact Dir.chdir 'libs' do - jruby_stdlib = JRubyJars::stdlib_jar_path.split('/')[-1] + jruby_stdlib = Dir['jruby-stdlib-*.jar'][-1] log_action("Reformatting #{jruby_stdlib}") do FileUtils.mkdir_p 'tmp' Dir.chdir 'tmp' do FileUtils.mkdir_p 'old' FileUtils.mkdir_p 'new/jruby.home' @@ -511,12 +521,11 @@ raise "Unpacking jruby-stdlib jar failed: #$?" unless $? == 0 end FileUtils.move 'old/META-INF/jruby.home/lib', 'new/jruby.home/lib' FileUtils.rm_rf 'new/jruby.home/lib/ruby/gems' - raise "Unrecognized JRuby stdlib jar: #{jruby_stdlib}" unless jruby_stdlib =~ /jruby-stdlib-(.*).jar/ - jruby_stdlib_version = Gem::Version.new($1) + jruby_stdlib_version = Gem::Version.new(JRubyJars::VERSION) if included_stdlibs lib_dirs = %w(1.8 1.9 2.0 shared) # FIXME(uwe): Remove when we stop testing JRuby < 1.7.4.dev @@ -574,10 +583,10 @@ next end # EMXIF # FIXME(uwe): These should be included but break the 64K method count limit - if j =~ /bcpkix-jdk15on-147|bcprov-jdk15on-147|jopenssl|kryptcore|kryptproviderjdk/ + if j =~ /bcpkix-jdk15on-1\.?47|bcprov-jdk15on-1\.?47|jopenssl|kryptcore|kryptproviderjdk/ FileUtils.rm j next end # EMXIF