Class: FastlaneCore::JavaTransporterExecutor

Inherits:
TransporterExecutor show all
Defined in:
fastlane_core/lib/fastlane_core/itunes_transporter.rb

Overview

Generates commands and executes the iTMSTransporter by invoking its Java app directly, to avoid the crazy parameter escaping problems in its accompanying shell script.

Constant Summary

Constants inherited from TransporterExecutor

TransporterExecutor::ITMS_PROVIDER_REGEX

Instance Method Summary collapse

Methods inherited from TransporterExecutor

#displayable_errors, #parse_provider_info, #prepare

Instance Method Details

#build_credential_params(username = nil, password = nil, jwt = nil, api_key = nil, is_password_from_env = false) ⇒ Object



560
561
562
563
564
565
566
567
568
569
570
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 560

def build_credential_params(username = nil, password = nil, jwt = nil, api_key = nil, is_password_from_env = false)
  if !username.nil? && jwt.to_s.empty?
    if is_password_from_env
      "-u #{username.shellescape} -p @env:ITMS_TRANSPORTER_PASSWORD"
    elsif !password.nil?
      "-u #{username.shellescape} -p #{password.shellescape}"
    end
  elsif !jwt.to_s.empty?
    "-jwt #{jwt}"
  end
end

#build_download_command(username, password, apple_id, destination = Dir.tmpdir, provider_short_name = "", jwt = nil) ⇒ Object



645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 645

def build_download_command(username, password, apple_id, destination = Dir.tmpdir, provider_short_name = "", jwt = nil)
  credential_params = build_credential_params(username, password, jwt, nil, is_default_itms_on_xcode_11?)
  if is_default_itms_on_xcode_11?
    [
      ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" if jwt.to_s.empty?),
      'xcrun iTMSTransporter',
      '-m lookupMetadata',
      credential_params,
      "-apple_id #{apple_id.shellescape}",
      "-destination #{destination.shellescape}",
      ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?),
      '2>&1' # cause stderr to be written to stdout
    ].compact.join(' ')
  else
    [
      Helper.transporter_java_executable_path.shellescape,
      "-Djava.ext.dirs=#{Helper.transporter_java_ext_dir.shellescape}",
      '-XX:NewSize=2m',
      '-Xms32m',
      '-Xmx1024m',
      '-Xms1024m',
      '-Djava.awt.headless=true',
      '-Dsun.net.http.retryPost=false',
      java_code_option,
      '-m lookupMetadata',
      credential_params,
      "-apple_id #{apple_id.shellescape}",
      "-destination #{destination.shellescape}",
      ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?),
      '2>&1' # cause stderr to be written to stdout
    ].compact.join(' ')
  end
end

#build_provider_ids_command(username, password, jwt = nil, api_key = nil) ⇒ Object



679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 679

def build_provider_ids_command(username, password, jwt = nil, api_key = nil)
  credential_params = build_credential_params(username, password, jwt, api_key, is_default_itms_on_xcode_11?)
  if is_default_itms_on_xcode_11?
    [
      ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" if jwt.to_s.empty?),
      'xcrun iTMSTransporter',
      '-m provider',
      credential_params,
      '2>&1' # cause stderr to be written to stdout
    ].compact.join(' ')
  else
    [
      Helper.transporter_java_executable_path.shellescape,
      "-Djava.ext.dirs=#{Helper.transporter_java_ext_dir.shellescape}",
      '-XX:NewSize=2m',
      '-Xms32m',
      '-Xmx1024m',
      '-Xms1024m',
      '-Djava.awt.headless=true',
      '-Dsun.net.http.retryPost=false',
      java_code_option,
      '-m provider',
      credential_params,
      '2>&1' # cause stderr to be written to stdout
    ].compact.join(' ')
  end
end

#build_upload_command(username, password, source = Dir.tmpdir, options = {}) ⇒ Object



572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 572

def build_upload_command(username, password, source = Dir.tmpdir, options = {})
  provider_short_name = options.fetch(:provider_short_name, "")
  jwt = options[:jwt]
  api_key = options[:api_key]
  credential_params = build_credential_params(username, password, jwt, api_key, is_default_itms_on_xcode_11?)
  if is_default_itms_on_xcode_11?
    [
      ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" if jwt.to_s.empty?),
      'xcrun iTMSTransporter',
      '-m upload',
      credential_params,
      file_upload_option(source),
      additional_upload_parameters, # that's here, because the user might overwrite the -t option
      '-k 100000',
      ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?),
      '2>&1' # cause stderr to be written to stdout
    ].compact.join(' ') # compact gets rid of the possibly nil ENV value
  else
    [
      Helper.transporter_java_executable_path.shellescape,
      "-Djava.ext.dirs=#{Helper.transporter_java_ext_dir.shellescape}",
      '-XX:NewSize=2m',
      '-Xms32m',
      '-Xmx1024m',
      '-Xms1024m',
      '-Djava.awt.headless=true',
      '-Dsun.net.http.retryPost=false',
      java_code_option,
      '-m upload',
      credential_params,
      file_upload_option(source),
      additional_upload_parameters, # that's here, because the user might overwrite the -t option
      '-k 100000',
      ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?),
      '2>&1' # cause stderr to be written to stdout
    ].compact.join(' ') # compact gets rid of the possibly nil ENV value
  end
end

#build_verify_command(username, password, source = Dir.tmpdir, options = {}) ⇒ Object



611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 611

def build_verify_command(username, password, source = Dir.tmpdir, options = {})
  provider_short_name = options.fetch(:provider_short_name, "")
  jwt = options[:jwt]
  credential_params = build_credential_params(username, password, jwt, nil, is_default_itms_on_xcode_11?)
  if is_default_itms_on_xcode_11?
    [
      ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" if jwt.to_s.empty?),
      'xcrun iTMSTransporter',
      '-m verify',
      credential_params,
      "-f #{source.shellescape}",
      ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?),
      '2>&1' # cause stderr to be written to stdout
    ].compact.join(' ') # compact gets rid of the possibly nil ENV value
  else
    [
      Helper.transporter_java_executable_path.shellescape,
      "-Djava.ext.dirs=#{Helper.transporter_java_ext_dir.shellescape}",
      '-XX:NewSize=2m',
      '-Xms32m',
      '-Xmx1024m',
      '-Xms1024m',
      '-Djava.awt.headless=true',
      '-Dsun.net.http.retryPost=false',
      java_code_option,
      '-m verify',
      credential_params,
      "-f #{source.shellescape}",
      ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?),
      '2>&1' # cause stderr to be written to stdout
    ].compact.join(' ') # compact gets rid of the possibly nil ENV value
  end
end

#execute(command, hide_output) ⇒ Object



727
728
729
730
731
732
733
734
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 727

def execute(command, hide_output)
  # The Java command needs to be run starting in a working directory in the iTMSTransporter
  # file area. The shell script takes care of changing directories over to there, but we'll
  # handle it manually here for this strategy.
  FileUtils.cd(Helper.itms_path) do
    return super(command, hide_output)
  end
end

#handle_error(password) ⇒ Object



719
720
721
722
723
724
725
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 719

def handle_error(password)
  unless File.exist?(Helper.transporter_java_jar_path)
    UI.error("The iTMSTransporter Java app was not found at '#{Helper.transporter_java_jar_path}'.")
    UI.error("If you're using Xcode 6, please select the shell script executor by setting the environment variable "\
      "FASTLANE_ITUNES_TRANSPORTER_USE_SHELL_SCRIPT=1")
  end
end

#is_default_itms_on_xcode_11?Boolean

Returns:



707
708
709
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 707

def is_default_itms_on_xcode_11?
  !Helper.user_defined_itms_path? && Helper.mac? && Helper.xcode_at_least?(11)
end

#java_code_optionObject



711
712
713
714
715
716
717
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 711

def java_code_option
  if Helper.mac? && Helper.xcode_at_least?(9)
    return "-jar #{Helper.transporter_java_jar_path.shellescape}"
  else
    return "-classpath #{Helper.transporter_java_jar_path.shellescape} com.apple.transporter.Application"
  end
end