gradle
All gradle related actions, including building and testing your application
Run
./gradlew tasks
to get a list of all available gradle tasks for your project
gradle | |
---|---|
Supported platforms | mac, linux, windows |
Author | @KrauseFx, @lmirosevic, @johnknapprs |
Returns | The output of running the gradle task |
1 Example
gradle( task: "assemble", flavor: "WorldDomination", build_type: "Release" )
To build an AAB use:
gradle( task: "bundle", flavor: "WorldDomination", build_type: "Release" )
You can pass properties to gradle:
gradle( # ... properties: { "versionCode" => 100, "versionName" => "1.0.0", # ... } )
You can use this to automatically [sign and zipalign] your app:
gradle( task: "assemble", build_type: "Release", print_command: false, properties: { "app.injected.signing.store.file" => "keystore.jks", "app.injected.signing.store.password" => "store_password", "app.injected.signing.key.alias" => "key_alias", "app.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 artifacts
gradle( task: "clean" )
Parameters
Key | Description | Default |
---|---|---|
task |
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 |
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_ARTIFACT _OUTPUT_PATH] then you must specify a flavor here or else this value will be undefined |
|
build_type |
The build type that you want the task for, e.g. Release . Useful for some tasks such as assemble |
|
flags |
All parameter flags you want to pass to the gradle command, e.g. --exitcode --xml file.xml |
|
project_dir |
The root directory of the gradle project | . |
gradle_path |
The path to your gradlew . If you specify a relative path, it is assumed to be relative to the project_dir |
./gradlew |
properties |
Gradle properties to be exposed to the gradle script | |
artifact_extension |
Gradle build output filetype extension | jar |
system_properties |
Gradle system properties to be exposed to the gradle script | |
print_command |
Control whether the generated Gradle command is printed as output before running it (true/false) | true |
print_command_output |
Control whether the output produced by given Gradle command is printed while running (true/false) | true |
* = default value is dependent on the user's system
Lane Variables
Actions can communicate with each other using a shared hash lane_context
, that can be accessed in other actions, plugins or your lanes: lane_context[SharedValues:XYZ]
. The gradle
action generates the following Lane Variables:
SharedValue | Description |
---|---|
SharedValues::GRADLE_ARTIFACT_OUTPUT_PATH |
The path to the newly generated artifact file. Undefined in a multi-variant assemble scenario |
SharedValues::GRADLE_FLAVOR |
The flavor, e.g. MyFlavor |
SharedValues::GRADLE_BUILD_TYPE |
The build type, e.g. Release |
To get more information check the Lanes documentation.
Documentation
To show the documentation in your terminal, run
pantograph action gradle
CLI
It is recommended to add the above action into your Pantfile
, however sometimes you might want to run one-offs. To do so, you can run the following command from your terminal
pantograph run gradle
To pass parameters, make use of the :
symbol, for example
pantograph run gradle parameter1:"value1" parameter2:"value2"
It's important to note that the CLI supports primitive types like integers, floats, booleans, and strings. Arrays can be passed as a comma delimited string (e.g. param:"1,2,3"
). Hashes are not currently supported.
It is recommended to add all pantograph actions you use to your Pantfile
.
Source code
This action, just like the rest of pantograph, is fully open source, view the source code on GitHub