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

- old
+ new

@@ -1,8 +1,9 @@ require 'ruboto/version' require 'ruboto/core_ext/rexml' require 'ruboto/sdk_locations' +require 'ruboto/util/build' module Ruboto module Util module Update include Build @@ -136,10 +137,11 @@ 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 + install_jruby_jars_gem begin require 'jruby-jars' rescue LoadError puts "Could not find the jruby-jars gem. You need it to include JRuby in your app. Please install it using\n\n gem install jruby-jars\n\n" return false @@ -177,10 +179,36 @@ puts "JRuby version is now: #{new_jruby_version}" true end + def install_jruby_jars_gem + if (jars_version_from_env = ENV['JRUBY_JARS_VERSION']) + version_requirement = " -v #{jars_version_from_env}" + end + `gem query -i -n jruby-jars#{version_requirement}` + unless $? == 0 + local_gem_dir = ENV['LOCAL_GEM_DIR'] || Dir.getwd + local_gem_file = "#{local_gem_dir}/jruby-jars-#{jars_version_from_env}.gem" + if File.exists?(local_gem_file) + system "gem install -l #{local_gem_file} --no-ri --no-rdoc" + else + system "gem install -r jruby-jars#{version_requirement} --no-ri --no-rdoc" + end + end + raise "install of jruby-jars failed with return code #$?" unless $? == 0 + if jars_version_from_env + exclusion_clause = %Q{-v "!=#{jars_version_from_env}"} + `gem query -i -n jruby-jars #{exclusion_clause}` + if $? == 0 + system %Q{gem uninstall jruby-jars --all #{exclusion_clause}} + raise "Uninstall of jruby-jars failed with return code #$?" unless $? == 0 + end + end + Gem.refresh + end + def update_dx_jar(force=nil) # FIXME(uwe): Remove when we stop updating from Ruboto 0.8.1 and older. FileUtils.rm(Dir['libs/dexmaker*.jar']) # EMXIF @@ -300,11 +328,11 @@ 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')} + app_element.add_element 'activity', {'android:name' => 'org.ruboto.SplashActivity', 'android:exported' => 'false', 'android:configChanges' => (target.to_i >= 13 ? 'orientation|screenSize' : 'orientation'), 'android:noHistory' => 'true'} 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 @@ -477,10 +505,10 @@ # `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.gsub("\\", "/")}/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.'