Configuring Maven to work with a SourceCraft registry
-
Create a personal access token (PAT).
-
Open the file with the global Maven settings.
By default, the configuration file is located in the current user's
.m2directory (~/.m2/settings.xmlfor Unix-like OSes and%USERPROFILE%\.m2\settings.xmlfor Windows). You can learn more about the configuration file structure in the Maven documentation. -
Add a new repository to the configuration file's
repositoriessection:<repository> <id>local</id> <url>pkg.sourcecraft.tech/maven/<organization_slug>/<registry_ID></url> </repository>Tip
You can find the organization slug and registry ID on the registry page in the SourceCraft UI.
-
Add a new server to the
serverssection of the Maven settings:<server> <id>local</id> <username>${env.REGISTRY_USERNAME}</username> <password>${env.REGISTRY_PASSWORD}</password> </server> -
Create the
REGISTRY_PASSWORDenvironment variable: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
<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>
See also
- SourceCraft resource relationships
- Creating a registry in SourceCraft
- Connecting a registry to a SourceCraft repository
- Configuring npm to work with a SourceCraft registry
- Configuring NuGet to work with a SourceCraft registry
- Configuring PyPI to work with the SourceCraft registry
- Configuring Docker to work with a SourceCraft registry