fastlane/lib/fastlane/actions/gradle.rb in fastlane-2.139.0 vs fastlane/lib/fastlane/actions/gradle.rb in fastlane-2.140.0
- old
+ new
@@ -15,17 +15,21 @@
GRADLE_FLAVOR = :GRADLE_FLAVOR
GRADLE_BUILD_TYPE = :GRADLE_BUILD_TYPE
end
class GradleAction < Action
+ # rubocop:disable Metrics/PerceivedComplexity
def self.run(params)
task = params[:task]
flavor = params[:flavor]
build_type = params[:build_type]
+ tasks = params[:tasks]
- gradle_task = [task, flavor, build_type].join
+ gradle_task = gradle_task(task, flavor, build_type, tasks)
+ UI.user_error!('Please pass a gradle task or tasks') if gradle_task.empty?
+
project_dir = params[:project_dir]
gradle_path_param = params[:gradle_path] || './gradlew'
# Get the path to gradle, if it's an absolute path we take it as is, if it's relative we assume it's relative to the project_dir
@@ -99,11 +103,33 @@
# 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
end
+ # rubocop:enable Metrics/PerceivedComplexity
+ def self.gradle_task(task, flavor, build_type, tasks)
+ gradle_task = [task, flavor, build_type].join
+
+ if gradle_task.empty? && !tasks.nil?
+ gradle_task = tasks.join(' ')
+ end
+
+ gradle_task
+ end
+
+ def self.step_text(params)
+ task = params[:task]
+ flavor = params[:flavor]
+ build_type = params[:build_type]
+ tasks = params[:tasks]
+
+ gradle_task = gradle_task(task, flavor, build_type, tasks)
+
+ return gradle_task
+ end
+
#####################################################
# @!group Documentation
#####################################################
def self.description
@@ -117,11 +143,12 @@
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :task,
env_name: 'FL_GRADLE_TASK',
description: 'The gradle task you want to execute, e.g. `assemble`, `bundle` or `test`. For tasks such as `assembleMyFlavorRelease` you should use gradle(task: \'assemble\', flavor: \'Myflavor\', build_type: \'Release\')',
- optional: false,
+ conflicting_options: [:tasks],
+ optional: true,
is_string: true),
FastlaneCore::ConfigItem.new(key: :flavor,
env_name: 'FL_GRADLE_FLAVOR',
description: 'The flavor that you want the task for, e.g. `MyFlavor`. If you are running the `assemble` task in a multi-flavor project, and you rely on Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH] then you must specify a flavor here or else this value will be undefined',
optional: true,
@@ -129,10 +156,17 @@
FastlaneCore::ConfigItem.new(key: :build_type,
env_name: 'FL_GRADLE_BUILD_TYPE',
description: 'The build type that you want the task for, e.g. `Release`. Useful for some tasks such as `assemble`',
optional: true,
is_string: true),
+ FastlaneCore::ConfigItem.new(key: :tasks,
+ type: Array,
+ env_name: 'FL_GRADLE_TASKS',
+ description: 'The multiple gradle tasks that you want to execute, e.g. `[assembleDebug, bundleDebug]`',
+ conflicting_options: [:task],
+ optional: true,
+ is_string: false),
FastlaneCore::ConfigItem.new(key: :flags,
env_name: 'FL_GRADLE_FLAGS',
description: 'All parameter flags you want to pass to the gradle command, e.g. `--exitcode --xml file.xml`',
optional: true,
is_string: true),
@@ -214,9 +248,16 @@
```ruby
gradle(
task: "bundle",
flavor: "WorldDomination",
build_type: "Release"
+ )
+ ```
+
+ You can pass multiple gradle tasks:
+ ```ruby
+ gradle(
+ tasks: ["assembleDebug", "bundleDebug"]
)
```
You can pass properties to gradle:
```ruby