Help Center/ CodeArts Artifact/ User Guide/ Self-Hosted Repos 2.0/ Managing a Repository/ Configuring the Encryption Mode of a Maven Repository
Updated on 2025-10-11 GMT+08:00

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:

  1. 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>

  2. 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.

  1. Add the nu.studer.credentials plug-in to the build.gradle file in the Gradle project.

    plugins{   
     id 'nu.studer.credentials' version '2.1'
    }

  2. 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\=\=

  3. 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/'
                     }
                   }