Added the following elements to pom.xml
:
<dependencies>
<dependency>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.3-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>maven-test</id>
<url>https://maven.pkg.github.com/jcansdale-test/*</url>
</repository>
</repositories>
Note, we can use https://maven.pkg.github.com/jcansdale-test/*
as the repository URL. The repository name is only significant when publishing packages.
Create a settings.xml
file for this repository:
I'm including an XML encoded token because I don't want it be automatically deleted by GitHub when it appears on a public repository. The token is a PAT with the read:packages
scope from an account that doesn't own any private packages and is therefore safe to share.
<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
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>maven-test</id>
<username>jcansdale-robot</username>
<!-- Public token with `read:packages` scope -->
<password>29d72a1b56270e6ace5317ff1b4442a6c3ced9ed</password>
</server>
</servers>
</settings>
If you have Docker installed, you can XML encode a read:packages
scoped token like this:
docker run jcansdale/gpr encode TOKEN
Add .mvn/maven.config
to use local settings file by default:
-s settings.xml
mvn package
mvn dependency:purge-local-repository