Cache Gradle dependencies on Bitrise

Caching Gradle dependencies might decrease build times. Give it a try if you haven't already.

Caching Gradle dependencies might decrease build times. Give it a try if you haven't already.

Setup

  1. Put the Cache:Pull step after the Git Clone step
  2. Put the Cache:Push step to the very end of the Workflow

If you use v1.0 or newer of the Cache steps and the latest Gradle Runner step then that’s all you have to do.

If you use an older Cache or Gradle Runner step:

  1. Select the Cache:Push step and specify the following paths for caching (Cache paths input):

$HOME/.gradle
./.gradle
Copy code
  1. Select the Cache:Push step and specify the following paths for update-check ignore (Ignore Paths from change check input):

$HOME/.gradle/caches/*.lock
$HOME/.gradle/caches/*.bin
./.gradle/*.lock
./.gradle/*.bin
Copy code

Example workflow


example:
  steps:
  - git-clone: {}
  - cache-pull: {}
  - gradle-runner:
      inputs:
      - gradle_file: "$BITRISE_PROJECT_PATH"
      - gradle_task: "$GRADLE_TASK"
  - cache-push:
      inputs:
      - cache_paths: |-
          $HOME/.gradle
          ./.gradle
      - ignore_check_on_paths: |-
          $HOME/.gradle/caches/*.lock
          ./.gradle/*.lock
          ./.gradle/*.bin
Copy code

Oh, did you know you can use caching to pass artifacts between builds?

Happy building! 🤖

No items found.
The Mobile DevOps Newsletter

Explore more topics

App development

Best practices from engineers on how to use Bitrise to build better apps, faster.

Community

Meet other Bitrise engineers, technology experts, power users, partners and join our BUGs.

Company

All the updates about Bitrise events, sponsorships, employees, and more.

Insights

Mobile development, latest tech, industry insights, and interviews with experts.

Mobile DevOps

Learn why mobile development is unique and requires a set of unique practices.

Releases

Stay tuned for the last updates, new features, and product improvements.

The Mobile DevOps Newsletter

Join 1000s of your peers. Sign up to receive Mobile DevOps tips, news, and best practice guides once every two weeks.