How to make mvn deploy prompt for password?

rodrigorgs picture rodrigorgs · Sep 8, 2014 · Viewed 20.4k times · Source

I'm currently storing my maven credentials in ~/.m2/settings.xml:

<server>
  <id>my_server_id</id>
  <username>my_username</username>
  <password>my_password</password>
</server>

However, I'm not satisfied with having the password in clear text, since the password is used for other services, so I'd rather prompt the user for the password when doing a mvn deploy. I'm deploying to a Nexus OSS install via https.

I know that the password can be encrypted, but since the encryption is reversible, this solution is not appropriate for my case.

Is there a way to make Maven prompt for a password when doing an https deploy?

Answer

ebo picture ebo · Sep 8, 2014

As mentioned this functionality is currently not supported in the plugin. Issue MDEPLOY-51 actually asks for this improvement:

Allow the user to supply a user name password for a remote server when the deploy goal is called. Currently you have to add the repository username and password to the server.xml file. It would be helpful if the user could be prompted for a username and password on the command line. The password should be hidden when it is entered.

I would suggest voting for this improvement, or possibly implement the functionality yourself.