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

Instance Method Details

#build_download_command(username, password, apple_id, destination = "/tmp", provider_short_name = "", jwt = nil) ⇒ Object



562
563
564
565
566
567
568
569
570
571
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
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 562

def build_download_command(username, password, apple_id, destination = "/tmp", provider_short_name = "", jwt = nil)
  use_jwt = !jwt.to_s.empty?
  if !Helper.user_defined_itms_path? && Helper.mac? && Helper.xcode_at_least?(11)
    [
      ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" unless use_jwt),
      'xcrun iTMSTransporter',
      '-m lookupMetadata',
      ("-u #{username.shellescape}" unless use_jwt),
      ("-p @env:ITMS_TRANSPORTER_PASSWORD" unless use_jwt),
      ("-jwt #{jwt}" if use_jwt),
      "-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',
      ("-u #{username.shellescape}" unless use_jwt),
      ("-p #{password.shellescape}" unless use_jwt),
      ("-jwt #{jwt}" if use_jwt),
      "-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



600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 600

def build_provider_ids_command(username, password, jwt = nil, api_key = nil)
  use_jwt = !jwt.to_s.empty?
  if !Helper.user_defined_itms_path? && Helper.mac? && Helper.xcode_at_least?(11)
    [
      ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" unless use_jwt),
      'xcrun iTMSTransporter',
      '-m provider',
      ("-u #{username.shellescape}" unless use_jwt),
      ("-p @env:ITMS_TRANSPORTER_PASSWORD" unless use_jwt),
      ("-jwt #{jwt}" if use_jwt),
      '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',
      ("-u #{username.shellescape}" unless use_jwt),
      ("-p #{password.shellescape}" unless use_jwt),
      ("-jwt #{jwt}" if use_jwt),
      '2>&1' # cause stderr to be written to stdout
    ].compact.join(' ')
  end
end

#build_upload_command(username, password, source = "/tmp", provider_short_name = "", jwt = nil, platform = nil, api_key = nil) ⇒ Object



485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 485

def build_upload_command(username, password, source = "/tmp", provider_short_name = "", jwt = nil, platform = nil, api_key = nil)
  use_jwt = !jwt.to_s.empty?
  if !Helper.user_defined_itms_path? && Helper.mac? && Helper.xcode_at_least?(11)
    [
      ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" unless use_jwt),
      'xcrun iTMSTransporter',
      '-m upload',
      ("-u #{username.shellescape}" unless use_jwt),
      ("-p @env:ITMS_TRANSPORTER_PASSWORD" unless use_jwt),
      ("-jwt #{jwt}" if use_jwt),
      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',
      ("-u #{username.shellescape}" unless use_jwt),
      ("-p #{password.shellescape}" unless use_jwt),
      ("-jwt #{jwt}" if use_jwt),
      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 = "/tmp", provider_short_name = "", **kwargs) ⇒ Object



525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 525

def build_verify_command(username, password, source = "/tmp", provider_short_name = "", **kwargs)
  jwt = kwargs[:jwt]
  use_jwt = !jwt.to_s.empty?
  if !Helper.user_defined_itms_path? && Helper.mac? && Helper.xcode_at_least?(11)
    [
      ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" unless use_jwt),
      'xcrun iTMSTransporter',
      '-m verify',
      ("-u #{username.shellescape}" unless use_jwt),
      ("-p @env:ITMS_TRANSPORTER_PASSWORD" unless use_jwt),
      ("-jwt #{jwt}" if use_jwt),
      "-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',
      ("-u #{username.shellescape}" unless use_jwt),
      ("-p #{password.shellescape}" unless use_jwt),
      ("-jwt #{jwt}" if use_jwt),
      "-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



648
649
650
651
652
653
654
655
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 648

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



640
641
642
643
644
645
646
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 640

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

#java_code_optionObject



632
633
634
635
636
637
638
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 632

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