本文介绍了如何将GitHub Package Registry软件包添加为Gradle依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有一个 GitHub项目,其中配置了Package Registry.它有两个软件包:

So, I have a GitHub project with a Package Registry configured. It has two packages:

软件包页面仅具有针对Maven的指令,此外,指令已损坏(maven install so57323260不是在Maven中添加依赖项的有效方法):

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):

问题是:如何在Gradle构建中添加该软件包? >

Question is: how do I add that package in a Gradle build?

推荐答案

新答案:

GitHub已发布官方指南:配置Gradle以与GitHub软件包一起使用.

GitHub has published the official guide: Configuring Gradle for use with GitHub Packages.

旧答案:

首先,在您的Gradle构建配置中将Github Package Registry配置为Maven存储库:

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>"
        }
    }
}

您可以在帐户设置页面中生成令牌.

现在,添加一个依赖项,例如:

Now, add a dependency like:

build.gradle.kts:

dependencies {
    implementation("so57323260:so57323260:1.0.0")
    implementation("so57323260:test:1.0.2")
}

此处groupId是存储库的名称,而artifactId是已发布程序包的名称.

Here groupId is the repo's name and artifactId is the name of the published package.

这篇关于如何将GitHub Package Registry软件包添加为Gradle依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 14:46
查看更多