For those who are worried about the security of personal access token, the official guide suggests to access the username and password through Gradle property or system property.
Step1: Set USERNAME and TOKEN as system property (with export
or set
), or create a gradle.properties
file under the project root folder like this:
gpr.user=<USERNAME>
gpr.token=<TOKEN>
Step2: Add the Github package registry with authentication in build.gradle:
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/OWNER/REPOSITORY")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
password = project.findProperty("gpr.token") ?: System.getenv("TOKEN")
}
}
}
Step 3: Add the package you want to consume in build.gradle:
dependencies {
implementation 'com.example:package:version'
}
For more details (including how to config Maven), see the instructions in the Wiki I contributed here: https://github.com/GumTreeDiff/gumtree/wiki/Getting-Started