> ## Documentation Index
> Fetch the complete documentation index at: https://docs.root.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Maven

> Configure Maven to use Root Library Catalog as a drop-in replacement for Maven Central.

## Configure \~/.m2/settings.xml

```xml theme={null}
<settings>
  <servers>
    <server>
      <id>root-io</id>
      <username>rootio</username>
      <password>${env.ROOT_TOKEN}</password>
    </server>
  </servers>

  <mirrors>
    <mirror>
      <id>root-io</id>
      <name>Root.io Mirror for All Maven Repositories</name>
      <url>https://pkg.root.io/maven/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>root-io</id>
      <repositories>
        <repository>
          <id>root-io</id>
          <name>Root.io Maven Patches</name>
          <url>https://pkg.root.io/maven/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>root-io</id>
          <name>Root.io Maven Plugins</name>
          <url>https://pkg.root.io/maven/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>root-io</activeProfile>
  </activeProfiles>
</settings>
```

## Fetch a Dependency

```bash theme={null}
export ROOT_TOKEN="your-token-here"
mvn dependency:get -Dartifact=com.example:your-artifact:1.2.3
```

## Run Maven

```bash theme={null}
export ROOT_TOKEN="your-token-here"
mvn -U test
```

## CI/CD

```yaml theme={null}
# GitHub Actions example
- name: Build with Maven
  run: mvn -U test
  env:
    ROOT_TOKEN: ${{ secrets.ROOT_TOKEN }}
```

## Troubleshooting

| Issue                        | Solution                                                                      |
| ---------------------------- | ----------------------------------------------------------------------------- |
| `401 Unauthorized`           | Verify `ROOT_TOKEN` is exported and `settings.xml` uses `${env.ROOT_TOKEN}`   |
| `Could not resolve artifact` | Confirm `mirrorOf` is set to `central`                                        |
| Checksum validation errors   | Expected - Root-patched artifacts have different checksums than Maven Central |
| SNAPSHOT artifacts           | Set `<snapshots><enabled>false</enabled></snapshots>`                         |
