Sha256: 31da17fd9466e7d37807f1d57c017a49d912c9aabe3fe7b888caa51275c916b3

Contents?: true

Size: 1.8 KB

Versions: 16

Compression:

Stored size: 1.8 KB

Contents

def calabash_build(app)
  keystore = read_keystore_info()
  if fingerprint_from_keystore != fingerprint_from_apk(app)
    puts "#{app} is not signed with the configured keystore '#{keystore["keystore_location"]}' Aborting!"
    exit 1
  end



  test_server_file_name = test_server_path(app)
  FileUtils.mkdir_p File.dirname(test_server_file_name) unless File.exist? File.dirname(test_server_file_name)

  unsigned_test_apk = File.join(File.dirname(__FILE__), '..', 'lib/calabash-android/lib/TestServer.apk')
  android_platform = Dir["#{ENV["ANDROID_HOME"].gsub("\\", "/")}/platforms/android-*"].last
  raise "No Android SDK found in #{ENV["ANDROID_HOME"].gsub("\\", "/")}/platforms/" unless android_platform
  Dir.mktmpdir do |workspace_dir|
    Dir.chdir(workspace_dir) do
      FileUtils.cp(unsigned_test_apk, "TestServer.apk")
      FileUtils.cp(File.join(File.dirname(__FILE__), '..', 'test-server/AndroidManifest.xml'), "AndroidManifest.xml")

      unless system %Q{"#{RbConfig.ruby}" -pi.bak -e "gsub(/#targetPackage#/, '#{package_name(app)}')" AndroidManifest.xml}
        raise "Could not replace package name in manifest"
      end

      unless system %Q{"#{ENV["ANDROID_HOME"]}/platform-tools/aapt" package -M AndroidManifest.xml  -I "#{android_platform}/android.jar" -F dummy.apk}
        raise "Could not create dummy.apk"
      end

      Zip::ZipFile.new("dummy.apk").extract("AndroidManifest.xml","customAndroidManifest.xml")
      Zip::ZipFile.open("TestServer.apk") do |zip_file|
        zip_file.add("AndroidManifest.xml", "customAndroidManifest.xml")
      end
    end
    sign_apk("#{workspace_dir}/TestServer.apk", test_server_file_name)
    begin

    rescue Exception => e
      log e
      raise "Could not sign test server"
    end
  end
  puts "Done signing the test server. Moved it to #{test_server_file_name}"
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
testautoa-0.4.1 bin/calabash-android-build.rb
calabash-android-0.4.2 bin/calabash-android-build.rb
calabash-android-0.4.1 bin/calabash-android-build.rb
calabash-android-0.4.0 bin/calabash-android-build.rb
calabash-android-0.4.0.pre18 bin/calabash-android-build.rb
testautoa-0.4.0.pre19 bin/calabash-android-build.rb
testautoa-0.4.0.pre18 bin/calabash-android-build.rb
testautoa-0.4.0.pre16 bin/calabash-android-build.rb
calabash-android-0.4.0.pre17 bin/calabash-android-build.rb
calabash-android-0.4.0.pre16 bin/calabash-android-build.rb
calabash-android-0.4.0.pre15 bin/calabash-android-build.rb
calabash-android-0.4.0.pre11 bin/calabash-android-build.rb
calabash-android-0.4.0.pre10 bin/calabash-android-build.rb
calabash-android-0.4.0.pre9 bin/calabash-android-build.rb
calabash-android-0.4.0.pre8 bin/calabash-android-build.rb
calabash-android-0.4.0.pre7 bin/calabash-android-build.rb