How to add GitHub Package Registry package as a Gradle dependency

徘徊边缘 提交于 2019-11-30 04:36:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!