Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make mvn deploy prompt for password?

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?

like image 528
rodrigorgs Avatar asked Sep 08 '14 14:09

rodrigorgs


People also ask

What is the difference between mvn install and mvn deploy?

mvn:install copies your packaged Maven module to your local repository (by default, in ~/. m2/repository ), to be accessed by other local Maven builds. mvn:deploy uploads your packaged Maven module to another (usually remote) repository, to be accessed by other, not necessarily local, Maven builds.

Does mvn deploy build?

So, the answer is yes, mvn deploy will execute install and build the project artifacts.

How does mvn deploy work?

The mvn deploy runs the deploy plugin which deploys an artifact to the remote repository. A project may include the main jar and associated sources and Javadoc jars. The sources jar contains the Java sources, and the Javadoc jar contains the generated Javadoc.


1 Answers

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.

like image 189
ebo Avatar answered Sep 20 '22 08:09

ebo