gradle
Community Action Reference: Inspected directly from Fastlane core ruby gem definitions.
Supported Platforms: ios, android
All gradle related actions, including building and testing your Android app
Details
Run ./gradlew tasks to get a list of all available gradle tasks for your project
Parameters & Options
Total options available: 12
| Key | Type | Env Variable | Default | Required | Description |
|---|---|---|---|---|---|
task |
String |
FL_GRADLE_TASK |
- |
No | 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’) |
flavor |
String |
FL_GRADLE_FLAVOR |
- |
No | 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 |
build_type |
String |
FL_GRADLE_BUILD_TYPE |
- |
No | The build type that you want the task for, e.g. Release. Useful for some tasks such as assemble |
tasks |
Array |
FL_GRADLE_TASKS |
- |
No | The multiple gradle tasks that you want to execute, e.g. [assembleDebug, bundleDebug] |
flags |
String |
FL_GRADLE_FLAGS |
- |
No | All parameter flags you want to pass to the gradle command, e.g. --exitcode --xml file.xml |
project_dir |
String |
FL_GRADLE_PROJECT_DIR |
. |
Yes | The root directory of the gradle project |
gradle_path |
String |
FL_GRADLE_PATH |
- |
No | The path to your gradlew. If you specify a relative path, it is assumed to be relative to the project_dir |
properties |
Hash |
FL_GRADLE_PROPERTIES |
- |
No | Gradle properties to be exposed to the gradle script |
system_properties |
Hash |
FL_GRADLE_SYSTEM_PROPERTIES |
- |
No | Gradle system properties to be exposed to the gradle script |
serial |
String |
FL_ANDROID_SERIAL |
- |
Yes | Android serial, which device should be used for this command |
print_command |
Fastlane::Boolean |
FL_GRADLE_PRINT_COMMAND |
true |
Yes | Control whether the generated Gradle command is printed as output before running it (true/false) |
print_command_output |
Fastlane::Boolean |
FL_GRADLE_PRINT_COMMAND_OUTPUT |
true |
Yes | Control whether the output produced by given Gradle command is printed while running (true/false) |
Lane Context Shared Values
This action writes the following values to Actions.lane_context[SharedValues::...]:
| Key | Description |
|---|---|
SharedValues::GRADLE_APK_OUTPUT_PATH |
The path to the newly generated apk file. Undefined in a multi-variant assemble scenario |
SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS |
When running a multi-variant assemble, the array of signed apk’s that were generated |
SharedValues::GRADLE_FLAVOR |
The flavor, e.g. MyFlavor |
SharedValues::GRADLE_BUILD_TYPE |
The build type, e.g. Release |
SharedValues::GRADLE_AAB_OUTPUT_PATH |
The path to the most recent Android app bundle |
SharedValues::GRADLE_ALL_AAB_OUTPUT_PATHS |
The paths to the most recent Android app bundles |
SharedValues::GRADLE_OUTPUT_JSON_OUTPUT_PATH |
The path to the most recent output.json file |
SharedValues::GRADLE_ALL_OUTPUT_JSON_OUTPUT_PATHS |
The path to the newly generated output.json files |
SharedValues::GRADLE_MAPPING_TXT_OUTPUT_PATH |
The path to the most recent mapping.txt file |
SharedValues::GRADLE_ALL_MAPPING_TXT_OUTPUT_PATHS |
The path to the newly generated mapping.txt files |
Examples
gradle( task: "assemble", flavor: "WorldDomination", build_type: "Release")To build an AAB use:
gradle( task: "bundle", flavor: "WorldDomination", build_type: "Release")You can pass multiple gradle tasks:
gradle( tasks: ["assembleDebug", "bundleDebug"])You can pass properties to gradle:
gradle( # ...
properties: { "exampleNumber" => 100, "exampleString" => "1.0.0", # ... })You can use this to change the version code and name of your app:
gradle( # ...
properties: { "android.injected.version.code" => 100, "android.injected.version.name" => "1.0.0", # ... })You can use this to automatically sign and zipalign your app:
gradle( task: "assemble", build_type: "Release", print_command: false, properties: { "android.injected.signing.store.file" => "keystore.jks", "android.injected.signing.store.password" => "store_password", "android.injected.signing.key.alias" => "key_alias", "android.injected.signing.key.password" => "key_password", })If you need to pass sensitive information through the gradle action, and don’t want the generated command to be printed before it is run, you can suppress that:
gradle( # ... print_command: false)You can also suppress printing the output generated by running the generated Gradle command:
gradle( # ... print_command_output: false)To pass any other CLI flags to gradle use:
gradle( # ...
flags: "--exitcode --xml file.xml")Delete the build directory, generated APKs and AABs
gradle( task: "clean")Source & Upstream
- Gem Action:
gradle.rb - Upstream Source: Inspect Ruby Implementation on GitHub
- Authors:
KrauseFx,lmirosevic