【发布时间】:2021-02-12 19:31:54
【问题描述】:
我有一个 Android 库,我想将其发布为依赖项,以供我们公司的不同同事私下使用。
我不确定,但 Github Packages 会将其公开,任何人都可以使用它。
有没有办法使用 Gitlab 或任何工具来做到这一点?
【问题讨论】:
标签: android dependencies gitlab android-library github-package-registry
我有一个 Android 库,我想将其发布为依赖项,以供我们公司的不同同事私下使用。
我不确定,但 Github Packages 会将其公开,任何人都可以使用它。
有没有办法使用 Gitlab 或任何工具来做到这一点?
【问题讨论】:
标签: android dependencies gitlab android-library github-package-registry
我已经使用 github 包完成了这项工作,在我提供令牌之前我无法访问它,所以我认为这使它成为私有的。
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/USERNAME/REPOSITORY")
credentials {
username = "USERNAME"
password = "TOKEN"
}
}
}
publications {
aar(MavenPublication) {
groupId 'com'
artifactId 'test'
version '1.0.0'
artifact("set your aar file location")
}
}
}
USERNAME = 您的 github 帐户用户名
REPOSITORY = 你的仓库名称
TOKEN = 此令牌已生成,您可以从您的帐户执行此操作
aar 文件= 当您在库构建文件下构建项目时会出现此文件。
然后你可以通过命令行运行发布$gradle publish
------ 将依赖项添加到项目中
给你项目gradle添加这个
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/USERNAME/REPOSITORY")
credentials {
/** Create github.properties in root project folder file with
** gpr.usr=GITHUB_USER_ID & gpr.key=PERSONAL_ACCESS_TOKEN
** Or set env variable GPR_USER & GPR_API_KEY if not adding a properties file**/
username = "USERNAME"
password = "TOEKN"
}
}
给你module gradle添加这个
实现 com:test:1.0.0
【讨论】: