---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.2
alternate:
  - https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/configure-maven.md
  - https://sourcecraft.dev/portal/docs/ru/sourcecraft/operations/configure-maven.md
  - href: en/sourcecraft/operations/configure-maven.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt

# Configuring Maven to work with a SourceCraft registry

1. [Create](https://sourcecraft.dev/portal/docs/en/sourcecraft/security/pat.md#create) a personal access token (PAT).
1. Open the file with the global Maven settings.

    By default, the configuration file is located in the current user's `.m2` directory (`~/.m2/settings.xml` for Unix-like OSes and `%USERPROFILE%\.m2\settings.xml` for Windows). Learn more about the configuration file structure in [this Maven guide](https://maven.apache.org/settings.html).
1. Add a new repository to the configuration file's `repositories` section:

    ```xml
    <repository>
        <id>local</id>
        <url>pkg.sourcecraft.tech/maven/<organization_slug>/<registry_ID></url>
    </repository>
    ```

    <!-- source: en/_includes/sourcecraft/get-slug-registry-id-notice.md -->
    {% note tip %}

    You can find the organization slug and registry ID on the registry page in the SourceCraft UI.

    {% endnote %}
    <!-- endsource: en/_includes/sourcecraft/get-slug-registry-id-notice.md -->

1. Add a new server to the `servers` section of the Maven settings:

    ```xml
    <server>
        <id>local</id>
        <username>${env.REGISTRY_USERNAME}</username>
        <password>${env.REGISTRY_PASSWORD}</password>
    </server>
    ```

1. Create the `REGISTRY_PASSWORD` environment variable:

    ```bash
    export REGISTRY_USERNAME=iam
    export REGISTRY_PASSWORD=<personal_access_token>
    ```

    Where `<personal_access_token>` stands for contents of the previously obtained personal access token.

## Template of a file with the global Maven settings {#config-template}

```xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">

  <activeProfiles>
    <activeProfile>sourcecraft</activeProfile>
  </activeProfiles>

  <profiles>
    <profile>
      <id>sourcecraft</id>

      <repositories>
        <repository>
          <id>central</id>
          <url>https://repo1.maven.org/maven2</url>
        </repository>
        <repository>
          <id>sourcecraft</id>
          <url>https://pkg.sourcecraft.tech/maven/<organization_slug>/<registry_ID></url>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>

  <servers>
    <server>
      <id>sourcecraft</id>
      <username>iam</username>
      <password><personal_token></password>
    </server>
  </servers>

</settings>
```

#### Useful links {#see-also}

* [SourceCraft resource relationships](https://sourcecraft.dev/portal/docs/en/sourcecraft/concepts/index.md)
* [Creating a registry in SourceCraft](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/packages-management.md)
* [Connecting a registry to a SourceCraft repository](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/connect-registry.md)
* [Configuring npm to work with a SourceCraft registry](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/configure-npm.md)
* [Configuring NuGet to work with a SourceCraft registry](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/configure-nuget.md)
* [Configuring PyPI to work with the SourceCraft registry](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/configure-pypi.md)
* [Configuring Docker to work with a SourceCraft registry](https://sourcecraft.dev/portal/docs/en/sourcecraft/operations/configure-docker.md)
