fastlane/lib/fastlane/actions/gradle.rb in fastlane-2.136.0 vs fastlane/lib/fastlane/actions/gradle.rb in fastlane-2.137.0

- old
+ new

@@ -8,10 +8,12 @@ GRADLE_ALL_APK_OUTPUT_PATHS = :GRADLE_ALL_APK_OUTPUT_PATHS GRADLE_AAB_OUTPUT_PATH = :GRADLE_AAB_OUTPUT_PATH GRADLE_ALL_AAB_OUTPUT_PATHS = :GRADLE_ALL_AAB_OUTPUT_PATHS GRADLE_OUTPUT_JSON_OUTPUT_PATH = :GRADLE_OUTPUT_JSON_OUTPUT_PATH GRADLE_ALL_OUTPUT_JSON_OUTPUT_PATHS = :GRADLE_ALL_OUTPUT_JSON_OUTPUT_PATHS + GRADLE_MAPPING_TXT_OUTPUT_PATH = :GRADLE_MAPPING_TXT_OUTPUT_PATH + GRADLE_ALL_MAPPING_TXT_OUTPUT_PATHS = :GRADLE_ALL_MAPPING_TXT_OUTPUT_PATHS GRADLE_FLAVOR = :GRADLE_FLAVOR GRADLE_BUILD_TYPE = :GRADLE_BUILD_TYPE end class GradleAction < Action @@ -61,34 +63,40 @@ return result unless task =~ /\b(assemble)/ || task =~ /\b(bundle)/ apk_search_path = File.join(project_dir, '**', 'build', 'outputs', 'apk', '**', '*.apk') aab_search_path = File.join(project_dir, '**', 'build', 'outputs', 'bundle', '**', '*.aab') output_json_search_path = File.join(project_dir, '**', 'build', 'outputs', 'apk', '**', 'output.json') + mapping_txt_search_path = File.join(project_dir, '**', 'build', 'outputs', 'mapping', '**', 'mapping.txt') # Our apk/aab is now built, but there might actually be multiple ones that were built if a flavor was not specified in a multi-flavor project (e.g. `assembleRelease`) # However, we're not interested in unaligned apk's... new_apks = Dir[apk_search_path].reject { |path| path =~ /^.*-unaligned.apk$/i } new_apks = new_apks.map { |path| File.expand_path(path) } new_aabs = Dir[aab_search_path] new_aabs = new_aabs.map { |path| File.expand_path(path) } new_output_jsons = Dir[output_json_search_path] new_output_jsons = new_output_jsons.map { |path| File.expand_path(path) } + new_mapping_txts = Dir[mapping_txt_search_path] + new_mapping_txts = new_mapping_txts.map { |path| File.expand_path(path) } # We expose all of these new apks and aabs Actions.lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS] = new_apks Actions.lane_context[SharedValues::GRADLE_ALL_AAB_OUTPUT_PATHS] = new_aabs Actions.lane_context[SharedValues::GRADLE_ALL_OUTPUT_JSON_OUTPUT_PATHS] = new_output_jsons + Actions.lane_context[SharedValues::GRADLE_ALL_MAPPING_TXT_OUTPUT_PATHS] = new_mapping_txts # We also take the most recent apk and aab to return as SharedValues::GRADLE_APK_OUTPUT_PATH and SharedValues::GRADLE_AAB_OUTPUT_PATH # This is the one that will be relevant for most projects that just build a single build variant (flavor + build type combo). # In multi build variants this value is undefined last_apk_path = new_apks.sort_by(&File.method(:mtime)).last last_aab_path = new_aabs.sort_by(&File.method(:mtime)).last last_output_json_path = new_output_jsons.sort_by(&File.method(:mtime)).last + last_mapping_txt_path = new_mapping_txts.sort_by(&File.method(:mtime)).last Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH] = File.expand_path(last_apk_path) if last_apk_path Actions.lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH] = File.expand_path(last_aab_path) if last_aab_path Actions.lane_context[SharedValues::GRADLE_OUTPUT_JSON_OUTPUT_PATH] = File.expand_path(last_output_json_path) if last_output_json_path + Actions.lane_context[SharedValues::GRADLE_MAPPING_TXT_OUTPUT_PATH] = File.expand_path(last_mapping_txt_path) if last_mapping_txt_path # Give a helpful message in case there were no new apks or aabs. Remember we're only running this code when assembling, in which case we certainly expect there to be an apk or aab UI.message('Couldn\'t find any new signed apk files...') if new_apks.empty? && new_aabs.empty? return result @@ -173,10 +181,12 @@ ['GRADLE_FLAVOR', 'The flavor, e.g. `MyFlavor`'], ['GRADLE_BUILD_TYPE', 'The build type, e.g. `Release`'], ['GRADLE_AAB_OUTPUT_PATH', 'The path to the most recent Android app bundle'], ['GRADLE_ALL_AAB_OUTPUT_PATHS', 'The paths to the most recent Android app bundles'], ['GRADLE_OUTPUT_JSON_OUTPUT_PATH', 'The path to the most recent output.json file'], - ['GRADLE_ALL_OUTPUT_JSON_OUTPUT_PATHS', 'The path to the newly generated output.json files'] + ['GRADLE_ALL_OUTPUT_JSON_OUTPUT_PATHS', 'The path to the newly generated output.json files'], + ['GRADLE_MAPPING_TXT_OUTPUT_PATH', 'The path to the most recent mapping.txt file'], + ['GRADLE_ALL_MAPPING_TXT_OUTPUT_PATHS', 'The path to the newly generated mapping.txt files'] ] end def self.return_value 'The output of running the gradle task'