问题
So, I have a GitHub project with a Package Registry configured. It has two packages:
Package pages have instructions only for Maven, besides that, the instructions are broken (maven install so57323260
is not a valid way to add a dependency in Maven):
Question is: how do I add that package in a Gradle build?
回答1:
New answer:
GitHub has published the official guide: Configuring Gradle for use with GitHub Packages.
Old answer:
First, configure Github Package Registry as a Maven repository in your Gradle build config:
build.gradle.kts:
repositories {
jcenter()
maven("https://maven.pkg.github.com/madhead") {
credentials {
username = "madhead"
password = "<token>"
}
}
}
You can generate a token in your account settings page.
Now, add a dependency like:
build.gradle.kts:
dependencies {
implementation("so57323260:so57323260:1.0.0")
implementation("so57323260:test:1.0.2")
}
Here groupId
is the repo's name and artifactId
is the name of the published package.
来源:https://stackoverflow.com/questions/57373192/how-to-add-github-package-registry-package-as-a-gradle-dependency