class Fastlane::Actions::ProguardAction

Constants

APP_PATH
MATCHES_FILES
OUTPUT_PATH
RELEASE_TYPE

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/debug_file/actions/proguard_action.rb, line 161
def self.authors
  ['icyleaf']
end
available_options() click to toggle source
# File lib/fastlane/plugin/debug_file/actions/proguard_action.rb, line 95
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :app_path,
                                 env_name: 'DF_PROGUARD_PATH',
                                 description: 'The path of app project',
                                 default_value: APP_PATH,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :build_type,
                                 env_name: 'DF_PROGUARD_BUILD_TYPE',
                                 description: 'The build type of app',
                                 default_value: RELEASE_TYPE,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :flavor,
                                 env_name: 'DF_PROGUARD_FLAVOR',
                                 description: 'The product flavor of app',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :extra_files,
                                 env_name: 'DF_PROGUARD_EXTRA_FILES',
                                 description: 'The extra files of app project',
                                 optional: true,
                                 default_value: [],
                                 type: Array),
    FastlaneCore::ConfigItem.new(key: :output_path,
                                 env_name: 'DF_PROGUARD_OUTPUT_PATH',
                                 description: "The output path of compressed proguard file",
                                 default_value: OUTPUT_PATH,
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :overwrite,
                                 env_name: 'DF_PROGUARD_OVERWRITE',
                                 description: "Overwrite output compressed file if it existed",
                                 default_value: false,
                                 type: Boolean)
  ]
end
category() click to toggle source
# File lib/fastlane/plugin/debug_file/actions/proguard_action.rb, line 147
def self.category
  :misc
end
description() click to toggle source

@!group Documentation

# File lib/fastlane/plugin/debug_file/actions/proguard_action.rb, line 91
def self.description
  'Find and generate Android proguard file(s) to zip file'
end
example_code() click to toggle source
# File lib/fastlane/plugin/debug_file/actions/proguard_action.rb, line 132
def self.example_code
  [
    'proguard',
    'proguard(
      build_type: "release",
      flavor: "full"
    )',
    'proguard(
      extra_files: [
        "app/src/main/AndroidManifest.xml"
      ]
    )'
  ]
end
find_proguard_files(app_path, build_type, flavor, extra_files) click to toggle source
# File lib/fastlane/plugin/debug_file/actions/proguard_action.rb, line 53
def self.find_proguard_files(app_path, build_type, flavor, extra_files)
  src_files = []
  MATCHES_FILES.each do |_, file|
    path, existed = find_file(app_path, file, build_type, flavor)
    UI.verbose("File path `#{path}` exist: #{existed}")
    next unless existed

    src_files << path
  end

  extra_files.each do |file|
    existed = File.exist?(file)
    UI.verbose("File path `#{file}` exist: #{existed}")
    next unless existed

    src_files << file
  end

  src_files.uniq
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/debug_file/actions/proguard_action.rb, line 165
def self.is_supported?(platform)
  platform == :android
end
output() click to toggle source
# File lib/fastlane/plugin/debug_file/actions/proguard_action.rb, line 155
def self.output
  [
    ['DF_PROGUARD_ZIP_PATH', 'the path of compressed proguard file']
  ]
end
return_value() click to toggle source
# File lib/fastlane/plugin/debug_file/actions/proguard_action.rb, line 151
def self.return_value
  String
end
run(params) click to toggle source
# File lib/fastlane/plugin/debug_file/actions/proguard_action.rb, line 32
def self.run(params)
  app_path = params[:app_path]
  build_type = params[:build_type]
  flavor = params[:flavor]
  overwrite = params[:overwrite]
  extra_files = params[:extra_files]
  output_path = params[:output_path]
  output_file = File.join(output_path, zip_filename(build_type, flavor))

  Helper::DebugFileHelper.determine_output_file(output_file, overwrite)

  src_files = find_proguard_files(app_path, build_type, flavor, extra_files)
  UI.user_error! 'No found any proguard file' if src_files.empty?

  UI.success "Found #{src_files.size} debug information files"
  Helper::DebugFileHelper.compress(src_files, output_file)

  UI.success "Compressed proguard files: #{output_file}"
  Helper::DebugFileHelper.store_shard_value SharedValues::DF_PROGUARD_ZIP_PATH, output_file
end

Private Class Methods

find_file(app_path, file, build_type, flavor) click to toggle source
# File lib/fastlane/plugin/debug_file/actions/proguard_action.rb, line 74
def self.find_file(app_path, file, build_type, flavor)
  flavor ||= ''
  path = File.join(app_path, file[:path], flavor, build_type, file[:name])
  [path, File.exist?(path)]
end
zip_filename(build_type, flavor = nil) click to toggle source
# File lib/fastlane/plugin/debug_file/actions/proguard_action.rb, line 81
def self.zip_filename(build_type, flavor = nil)
  flavor = flavor.to_s.empty? ? '' : "#{flavor}-"
  "#{flavor}#{build_type}-proguard.zip"
end