How can I use an Encrypted Password to a Maven Repository in Gradle

橙三吉。 提交于 2019-12-30 05:46:08

问题


I'm currently trying to transisiton a maven build to a Gradle build. The show stopper hurdle I've hit is that our internal artifacts are deployed to an internal repository that requires authentication to read.

And you know what authentication means... usernames and passwords. The problem is I don't want to require developers to store their password as plaintext on their hard drives. Maven supports password encryption but I'm not seeing how to make Gradle do it.

Is there some magic access to the Ivy CredentialStore that will support encrypted passwords? or will I have to wait for a new version?


回答1:


We use Artifactory and Ivy's CredentialsStore works fine.

repositories {
  org.apache.ivy.util.url.CredentialsStore.INSTANCE.addCredentials(REALM, HOST, USER, PASSWORD);
  mavenRepo urls: [ "http://repo.mycompany.com/repo" ]
}

To have each developer use a different username create a gradle.properties file that contains

HOST=repo.mycompany.com
REALM=My Company Realm
USER=theusername
PASSWORD={DESede}xyz123abc

The {DESede} encrypted password prefix may be a Artifactory specific convention.




回答2:


The gradle-credentials plugin will let you encrypt the contents of a gradle.encrypted.properties file, which will then be available in the build as properties of the credentials object.

The gradle maven settings plugin will let you use Maven's system for encrypting/decrypting credentials.



来源:https://stackoverflow.com/questions/4514479/how-can-i-use-an-encrypted-password-to-a-maven-repository-in-gradle

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