Class: Fastlane::Actions::GetApplicationIdAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/gradle_manager/actions/get_application_id_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



30
31
32
# File 'lib/fastlane/plugin/gradle_manager/actions/get_application_id_action.rb', line 30

def self.authors
  ['Helder Pinhal']
end

.available_optionsObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fastlane/plugin/gradle_manager/actions/get_application_id_action.rb', line 45

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :cached_data,
                                 env_name: 'GRADLE_MANAGER_CACHED_DATA',
                                 description: 'The cached data from get_gradle_data. If not supplied then the action will try to fetch it',
                                 optional: true,
                                 type: Hash,
                                 default_value: nil),
    FastlaneCore::ConfigItem.new(key: :module_name,
                                 env_name: 'GRADLE_MANAGER_MODULE_NAME',
                                 description: 'The name of the application source folder in the Android project (default: app)',
                                 optional: true,
                                 type: String,
                                 default_value: 'app'),
    FastlaneCore::ConfigItem.new(key: :gradle_file_path,
                                 env_name: 'GRADLE_MANAGER_GRADLE_FILE_PATH',
                                 description: 'The relative path to the gradle file (default:app/build.gradle)',
                                 optional: true,
                                 type: String,
                                 default_value: nil),
    FastlaneCore::ConfigItem.new(key: :flavor_name,
                                 env_name: 'GRADLE_MANAGER_FLAVOR_NAME',
                                 description: 'The name of the product flavor',
                                 optional: true,
                                 type: String,
                                 default_value: nil)
  ]
end

.descriptionObject



26
27
28
# File 'lib/fastlane/plugin/gradle_manager/actions/get_application_id_action.rb', line 26

def self.description
  'Get the parsed Gradle file of an Android project.'
end

.detailsObject



38
39
40
41
42
43
# File 'lib/fastlane/plugin/gradle_manager/actions/get_application_id_action.rb', line 38

def self.details
  [
    'Get the parsed Gradle file of an Android project.',
    'This action will return the parsed Gradle file based on the path you\'ve specified.'
  ].join('\n')
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/fastlane/plugin/gradle_manager/actions/get_application_id_action.rb', line 74

def self.is_supported?(platform)
  [:android].include?(platform)
end

.return_valueObject



34
35
36
# File 'lib/fastlane/plugin/gradle_manager/actions/get_application_id_action.rb', line 34

def self.return_value
  'Returns the parsed Gradle file.'
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fastlane/plugin/gradle_manager/actions/get_application_id_action.rb', line 4

def self.run(params)
  flavor ||= params[:flavor_name]

  begin
    gradle_data ||= params[:cached_data]

    if gradle_data.nil?
      gradle_file_path = Helper::GradleFileFinderHelper.find_file(params)
      gradle_data = Helper::GradleParserHelper.parse(gradle_file_path)
    end

    application_id = Helper::GradleDataFinderHelper.find_property(gradle_data, :application_id, flavor)

    application_id_suffix = Helper::GradleDataFinderHelper.find_property(gradle_data, :application_id_suffix, flavor)
    application_id += application_id_suffix unless application_id_suffix.nil?

    return application_id
  rescue => err
    UI.error("An exception occurred while parsing the gradle file: #{err}")
  end
end