Maven - (Password|Credentials)

> Maven

1 - About

How to manage credentials:

  • login
  • password

within Maven

Advertising

3 - Steps

3.1 - Create the master password

  • Encrypt the master password
mvn --encrypt-master-password <MasterPassword>
# or
mvn -emp <MasterPassword>
  • Saved it by creating the file m2_home/.m2/settings-security.xml
<settingsSecurity>
      <master>The master password created above {jSMOWnoPFgsHVpMvz5VrIt5kRbzGpI8u+9EF1iFQyJQ=}</master>
</settingsSecurity>

3.2 - Generate password and define credentials

mvn --encrypt-password <Password>
# or
mvn --ep <Password>

And save it in the settings.xml file.

<settings>
...
  <servers>
...
    <server>
      <id>my.server</id>
      <username>foo</username>
      <password>Oleg reset this password on 2009-03-11, expires on 2009-04-11 {COQLCE6DU6GtcS5P=}</password>
    </server>
...
  </servers>
...
</settings>

3.3 - Verify that the server id is the same than in your pom.xml

In the deploy phase, you distribute the artifacts (jar, site, …) on remote server (or repository). The repository id must then correspond to the server id

Example:

<distributionManagement>
        <repository>
            <id>my.server</id>
            <name>Bytle Remote</name>
            <url>scp://ftp.bytle.net:22</url>
        </repository>
    </distributionManagement>
Advertising

4 - Documentation / Reference

5 - Support

5.1 - Given final block not properly padded

[ERROR] Error executing Maven.
[ERROR] javax.crypto.BadPaddingException: Given final block not properly padded
[ERROR] Caused by: Given final block not properly padded

There is a lot of chance that your settings-security.xml file was not saved or is not correct.