何处放置不应该提交的Gradle配置(即凭据)? [英] Where to put Gradle configuration (i.e. credentials) that should not be committed?
本文介绍了何处放置不应该提交的Gradle配置(即凭据)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将一个Gradle构建的工件部署到Maven repo,并且我需要为其指定凭证。这适用于现在:
uploadArchives {
repositories {
mavenDeployer {
repository(url:http://.../nexus/content/repositories/snapshots/){
authentication(userName:admin,password:admin123)
}
}
}
}
不喜欢在源代码控制中存储凭据。使用Maven,我将定义一个服务器配置,并在我的〜/ .m2 / settings.xml
中分配凭证。我如何做类似于Gradle的事情?
mavenUser = admin
mavenPassword = admin123
build.gradle :
.. 。
authentication(userName:mavenUser,password:mavenPassword)
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")
}
}
}
}
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屋!
查看全文