We use cookies to understand how people use Depot.
Cache

Gradle

Gradle is the build tool of choice for Java, Android, and Kotlin. It is used in many large projects, including Android itself, and is optimized for incremental builds, advanced local and remote caching, and parallel execution. Gradle supports many different languages and platforms, and is highly configurable, scaling to codebases of any size.

Depot Cache provides a remote cache service that can be used with Gradle, allowing you to incrementally cache and reuse parts of your builds. This cache is accessible from anywhere, both on your local machine and on CI/CD systems.

Configuring Gradle to use Depot Cache

Depot Cache can be used with Gradle from Depot's managed GitHub Actions runners, from your local machine, or from any CI/CD system.

From Depot-managed Actions runners

Depot GitHub Actions runners are pre-configured to use Depot Cache with Gradle - each runner is launched with an init.gradle file that is pre-populated with the connection details for Depot Cache. You will need to verify that caching is enabled in your gradle.properties file.

org.gradle.caching=true

If this automatic configuration is incompatible with your specific setup, you can disable automatic configuration in your organization settings page and manually configure Gradle to use Depot Cache as described below.

From your local machine or any CI/CD system

To manually configure Gradle to use Depot Cache, you will need to configure remote caching in your settings.gradle file. Configure Gradle to use the Depot Cache service endpoints and set your API token in the Authorization header:

settings.gradle:

buildCache {
    remote(HttpBuildCache) {
        url = 'https://cache.depot.dev'
        enabled = true
        push = true
        headers {
            header 'Authorization', 'DEPOT_TOKEN'
        }
    }
}

If you are a member of multiple organizations, and you are authenticating with a user token, you must additionally specify which organization to use for cache storage with the x-depot-org header:

buildCache {
    remote(HttpBuildCache) {
        ...
        headers {
            header 'Authorization', 'DEPOT_TOKEN'
            header 'x-depot-org', 'DEPOT_ORG_ID'
        }
    }
}

Using Depot Cache with Gradle

Once Gradle is configured to use Depot Cache, you can then run your builds as you normally would. Gradle will automatically communicate with Depot Cache to fetch and reuse any stored build artifacts from your previous builds.