class Fastlane::Actions::AndroidUpdatePackageIdentifierAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/android_update_package_identifier/actions/android_update_package_identifier_action.rb, line 25
def self.authors
  ["Jonathan Nogueira"]
end
available_options() click to toggle source
# File lib/fastlane/plugin/android_update_package_identifier/actions/android_update_package_identifier_action.rb, line 34
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :gradleFilePath,
                            env_name: "ANDROID_UPDATE_PACKAGE_IDENTIFIER_GRADLE_FILE_PATH",
                         description: "Path to the gradle file you want to edit",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :newIdentifier,
                            env_name: "ANDROID_UPDATE_PACKAGE_IDENTIFIER_NEW_IDENTIFIER",
                         description: "The new app identifier you want to set the package to",
                            optional: false,
                                type: String),
  ]
end
description() click to toggle source
# File lib/fastlane/plugin/android_update_package_identifier/actions/android_update_package_identifier_action.rb, line 21
def self.description
  "Changes the applicationId inside of your build.gradle file. Does not change the AndroidManifest"
end
details() click to toggle source
# File lib/fastlane/plugin/android_update_package_identifier/actions/android_update_package_identifier_action.rb, line 29
def self.details
  # Optional:
  "This Fastlane plugin will change the applicationId to whatever you want inside your app's build.gradle file. This does not change the AndroidManifest, if you'd like to do that you need to make sure the code you have in your application matches up with what's built through the manifest."
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/android_update_package_identifier/actions/android_update_package_identifier_action.rb, line 49
def self.is_supported?(platform)
  [:android].include?(platform)
end
run(params) click to toggle source
# File lib/fastlane/plugin/android_update_package_identifier/actions/android_update_package_identifier_action.rb, line 7
def self.run(params)
  path = params[:gradleFilePath]
  identifier = params[:newIdentifier]

  File.open(path,"r+") do |file|
    text = File.read(file)
    UI.message("Changing build config at #{path} to have applicationId of #{identifier}")
    config_contents = text[/defaultConfig (\{(?:\{??[^\{]*?\}))/, 1]
    new_config_contents = config_contents.gsub(/(?<=applicationId \").*?(?=\")/, identifier)
    new_contents = text.gsub(config_contents, new_config_contents)
    file.puts new_contents
  end
end