不应提交的 Gradle 配置(即凭据)放在哪里? [英] Where to put Gradle configuration (i.e. credentials) that should not be committed?

查看:18
本文介绍了不应提交的 Gradle 配置(即凭据)放在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Gradle 构建的工件部署到 Maven 存储库,我需要为此指定凭据.这现在工作正常:

I'm trying to deploy a Gradle-built artifact to a Maven repo, and I need to specify credentials for that. This works fine for now:

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "http://.../nexus/content/repositories/snapshots/") {
                authentication(userName: "admin", password: "admin123")
            }
        }
    }
}

但我不喜欢将凭据存储在源代码管理中.使用 Maven,我将定义服务器配置,并在我的 ~/.m2/settings.xml 中分配凭据.我如何用 Gradle 做类似的事情?

But I don't like having to store the credentials in source control. With Maven, I would define a server configuration, and assign credentials in my ~/.m2/settings.xml. How do I do something similar with Gradle?

推荐答案

~/.gradle/gradle.properties:

mavenUser=admin
mavenPassword=admin123

build.gradle:

...
authentication(userName: mavenUser, password: mavenPassword)

这篇关于不应提交的 Gradle 配置(即凭据)放在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆