This repository hosts MBARI's public Maven artifacts.
GitHub packages requires authentication, even for public packages. To access MBARI public maven artifacts, you will need a [GitHub] account and a GitHub personal access token with at least read:packages
scope.
- Click on your user icon in GitHub and select
Settings
. - Select
Developer Settings
near the bottom of the left sidebar. - Select
Personal access token
. - Click on the
Generate new token
button on the top left. - Select your desired scopes. Be sure to include
read:packages
and then click theGenerate token
button near the bottom. - Copy your token and save it somewhere secure.
Open or create the file ~/.m2/settings.xml
. Then add the following:
<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">
<servers>
<!-- Github access token section -->
<server>
<id>github</id>
<username>your github username</username>
<password>your github access token</password>
</server>
</servers>
</settings>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>github</id>
<name>github</name>
<url>https://maven.pkg.github.com/mbari-org/maven</url>
</repository>
</repositories>
Set your github username and token as environment variables. For example, in bash:
export GITHUB_USERNAME 'your github username'
export GITHUB_TOKEN 'your github token'
Add the repository to your build.gradle
file as:
repositories {
maven {
name = "MBARI"
url = uri("https://maven.pkg.github.com/mbari-org/maven")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
}
}
}
There is an sbt-github-packages plugin. Notes about publication can be found here.
First, configure your personal access token as described above.
Add the following to your pom.xml
:
<distributionManagement>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/mbari-org/maven</url>
</repository>
</distributionManagement>
To publish to GPR run mvn deploy
Add the following to your root build.gradle
in your project:
subprojects {
// ...
apply plugin: 'maven-publish'
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/mbari-org/maven")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_USER")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
}
}
}
publications {
gpr(MavenPublication) {
groupId "my.projects.package"
artifactId project.name
from components.java
}
}
}
}