# Gradle Build Cache

Avrea provides a build cache endpoint for Gradle. Build outputs are cached
so that tasks with unchanged inputs are never re-executed.

## On Avrea runners

Gradle is pre-configured via `~/.gradle/init.gradle`:

```groovy title="~/.gradle/init.gradle"
gradle.settingsEvaluated { settings ->
    settings.buildCache {
        remote(HttpBuildCache) {
            url = uri("http://cache.avrea.com:8290/gradle-build/cas/")
            push = true
            allowInsecureProtocol = true
        }
    }
}
```

Your workflow needs no changes to point at Avrea. Just make sure the Gradle
build cache is enabled (`--build-cache` flag or `org.gradle.caching=true` in
`gradle.properties`):

```yaml title="workflow.yml"
jobs:
  build:
    runs-on: avrea-ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-java@v6
        with:
          distribution: temurin
          java-version: '21'
      - run: ./gradlew build --build-cache
```

## Manual setup

Add to your project `settings.gradle`:

```groovy title="settings.gradle"
// settings.gradle
buildCache {
    remote(HttpBuildCache) {
        url = uri("http://cache.avrea.com:8290/gradle-build/cas/")
        push = true
        allowInsecureProtocol = true
    }
}
```

Then enable it in your workflow:

```yaml
- run: ./gradlew build --build-cache
```

The `--build-cache` flag enables the remote build cache. You can also set
`org.gradle.caching=true` in `gradle.properties` to enable it by default.

## Cache stats

On Linux and macOS runners, Gradle 8.1.1 and later reports aggregate task
outcomes and selected task details alongside Gradle cache traffic. The
detailed list is bounded and prioritizes failed and slower tasks; aggregate
counts cover every observed task. See [Cache Stats](/cache/stats/) for
the outcome definitions, limits, and coverage states.