Configuring the Encryption Mode of a Maven Repository
Dependency Management Tool: Maven
- Ensure that you have installed JDK and Maven.
- Download the configuration file, or modify the Maven settings.xml file in the conf or .m2 directory as follows.
To encrypt a password, perform the following operations:
- Create a master password.
mvn --encrypt-master-password <password>
An encrypted password is generated, for example, {jSMOWnoPFgsHVpMvz5VrIt5kRbzGpI8u+9EF1iFQyJQ=}.
Save it to the ${user.home}/.m2/settings-security.xml file. For example:
<settingsSecurity> <master>{jSMOWnoPFgsHVpMvz5VrIt5kRbzGpI8u+9EF1iFQyJQ=}</master> </settingsSecurity>
- Encrypt the password.
mvn --encrypt-password <password>
An encrypted password is generated, for example: {COQLCE6DU6GtcS5P=}.
Save it to the settings.xml file. For example:
<settingsSecurity> <master>{jSMOWnoPFgsHVpMvz5VrIt5kRbzGpI8u+9EF1iFQyJQ=}</master> </settingsSecurity>
Dependency Management Tool: Gradle
Prerequisites: You have installed JDK and Gradle.
- Add the nu.studer.credentials plug-in to the build.gradle file in the Gradle project.
plugins{ id 'nu.studer.credentials' version '2.1' }
- Create an encryption password.
gradle addCredentials -PcredentialsKey=accountPassword -PcredentialsValue="**"
The following encrypted password is generated: cVe******kg\=\=.
By default, the data is stored in the GRADLE_USER_HOME/gradle.encrypted.properties file. For example:
accountPassword=cVe******kg\=\=
- Configure the repository with an encrypted password in the build.gradle file.
def password = credentials.accountPassword repositories { maven { credentials { username 'cn-north-1_f9e40463c23845438ca9efd3a7ec854e_67902fb51ded48c2868310a07e1569e7' password password } url 'https://devrepo.****.com/artgalaxy/cn-north-1_f9e40463c23845438ca9efd3a7ec854e_maven_1_7/' } }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot