This is the way it currently works, and it's the Maven Deploy Plugin Usage
pom.xml
[...] <distributionManagement> <repository> <id>internal.repo</id> <name>MyCo Internal Repository</name> <url>Host to Company Repository</url> </repository> </distributionManagement> [...]
settings.xml
[...] <server> <id>internal.repo</id> <username>someUser</username> <password>somePassword</password> </server> [...]
and what I'm trying to achieve is finding a way in which the username and password are typed in at the command line. to achieve mvn deploy -someUser -somePassword
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.
mvn deploy. This command invokes the deploy phase: deploy : copies the final package to the remote repository for sharing with other developers and projects.
deploy:deploy is used to automatically install the artifact, its pom and the attached artifacts produced by a particular project. Most if not all of the information related to the deployment is stored in the project's pom. deploy:deploy-file is used to install a single artifact along with its pom.
Using the maven-deploy-plugin We need to specify the version and plugin in the <pluginManagement> tag of the pom. xml file to define the version of the plugin in parent pom and specify the version and plugin in the plugins section of the pom file to use the goals of the plugin by your project or your parent project.
The settings.xml
is considered personal, so for that reason the username+password are stored in the (user-)settings.xml
. So in general there's no reason to pass them as argument. (btw, passwords can be stored encrypted here) The maven-deploy-plugin
has no option to pass them via commandline. However, I've seen hacks like:
<username>${internal.repo.username}</username>
And now you can do -Dinternal.repo.username=someUser
I'll lay out here the full solution, but basically Robert Scholte's solution works brilliant.
In your ~/.m2/settings.xml
you should have the following
<settings> <servers> <server> <id>${repo.id}</id> <username>${repo.login}</username> <password>${repo.pwd}</password> </server> </servers> </settings>
and then you just
mvn -Drepo.id=myRepo -Drepo.login=someUser -Drepo.pwd=somePassword clean install
You can even use your environment variable (if you are doing that on the remote server/container, for example):
mvn -Drepo.id=$REPO_ID -Drepo.login=$REPO_LOGIN -Drepo.pwd=$REPO_PWD clean install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With