bin/calabash-android-build.rb in calabash-android-0.1.0 vs bin/calabash-android-build.rb in calabash-android-0.2.0.pre2

- old
+ new

@@ -1,10 +1,12 @@ -def calabash_build(args) - run_setup_if_settings_does_not_exist +def calabash_build(app) - @settings = JSON.parse(IO.read(".calabash_settings")) - test_server_template_dir = File.join(File.dirname(__FILE__), '..', 'test-server') + + + keystore = read_keystore_info() + + test_server_template_dir = File.join(File.dirname(__FILE__), '..', 'test-server') Dir.mktmpdir do |workspace_dir| @test_server_dir = File.join(workspace_dir, 'test-server') FileUtils.cp_r(test_server_template_dir, workspace_dir) @@ -13,18 +15,18 @@ Dir.chdir(@test_server_dir) { args = [ ant_executable, "clean", "package", - "-Dtested.package_name=#{@settings["package_name"]}", - "-Dtested.main_activity=#{@settings["activity_name"]}", - "-Dtested.project.apk=#{@settings["app_path"]}", - "-Dandroid.api.level=#{@settings["api_level"]}", - "-Dkey.store=#{@settings["keystore_location"]}", - "-Dkey.store.password=#{@settings["keystore_password"]}", - "-Dkey.alias=#{@settings["keystore_alias"]}", - "-Dkey.alias.password=#{@settings["keystore_alias_password"]}", + "-Dtested.package_name=#{package_name(app)}", + "-Dtested.main_activity=#{main_activity(app)}", + "-Dtested.project.apk=#{app}", + "-Dandroid.api.level=#{api_level}", + "-Dkey.store=#{keystore["keystore_location"]}", + "-Dkey.store.password=#{keystore["keystore_password"]}", + "-Dkey.alias=#{keystore["keystore_alias"]}", + "-Dkey.alias.password=#{keystore["keystore_alias_password"]}", ] STDOUT.sync = true IO.popen(args.join(" ")) do |io| io.each { |s| print s } end @@ -33,11 +35,25 @@ exit $?.exitstatus end } test_apk = File.join(@test_server_dir, "bin", "Test.apk") - FileUtils.cp(test_apk, File.join(@support_dir, "Test.apk")) - puts "Done building the test server. Moved it to features/support/Test.apk" + test_server_file_name = "#{checksum(app)}.apk" + FileUtils.cp(test_apk, File.join(@support_dir, test_server_file_name)) + puts "Done building the test server. Moved it to features/support/#{test_server_file_name}" + end +end + +def read_keystore_info + if File.exist? ".calabash_settings" + JSON.parse(IO.read(".calabash_settings")) + else + { + "keystore_location" => "#{ENV["HOME"]}/.android/debug.keystore", + "keystore_password" => "android", + "keystore_alias" => "androiddebugkey", + "keystore_alias_password" => "android" + } end end def is_windows? ENV["OS"] == "Windows_NT" \ No newline at end of file