Cache Gradle dependencies on Bitrise

Bitrise
Bitrise
Published in
1 min readSep 13, 2018

--

Caching Gradle dependencies might decrease build times on Bitrise. 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:

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

$HOME/.gradle
./.gradle

4. 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

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

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

Happy building! 🤖

Originally published on the Bitrise blog.

--

--

Bitrise
Bitrise

Build better mobile applications, faster: Mobile Continuous Integration and Delivery with +330 of integrations for your favorite services. 🚀 https://bitrise.io