# Maven / Gradle Packages

import { Tabs, TabItem, Aside } from '@astrojs/starlight/components';

Avrea caches artifacts from Maven Central so that dependency resolution in Maven
and Gradle resolves from colocated cache on repeat runs.

<Aside>
This page covers **dependency downloads** from Maven Central. For **build output
caching** (skipping recompilation), see [Maven Build Cache](/cache/build-cache/maven/)
and [Gradle Build Cache](/cache/build-cache/gradle/).
</Aside>

## On Avrea runners

Maven and Gradle are pre-configured to use the colocated cache as a mirror for Maven
Central.

Your workflow needs no changes:

<Tabs>
  <TabItem label="Maven">
```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: mvn verify
```
  </TabItem>
  <TabItem label="Gradle">
```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
```
  </TabItem>
</Tabs>

## Manual setup

<Aside type="caution">
`cache.avrea.com` is reachable only from Avrea runners. Apply these settings on
Avrea runners that don't already pick up the pre-configured mirror; off-platform
environments should keep using Maven Central / the default Gradle repositories.
</Aside>

<Tabs>
  <TabItem label="Maven">
Add to `~/.m2/settings.xml`:

```xml title="~/.m2/settings.xml"
<settings>
  <mirrors>
    <mirror>
      <id>avrea-cache</id>
      <mirrorOf>central</mirrorOf>
      <url>https://cache.avrea.com:8443/maven/</url>
    </mirror>
  </mirrors>
</settings>
```

  </TabItem>
  <TabItem label="Gradle">
Add to `~/.gradle/init.gradle`:

```groovy title="~/.gradle/init.gradle"
allprojects {
    repositories {
        maven {
            url "https://cache.avrea.com:8443/maven/"
        }
    }
}
```

  </TabItem>
</Tabs>