Using a local repo manager and OSSRH

The following was submitted by Eric Kolotyluk, a Maven and maven-deploy-plugin user. Thanks Eric!

You may be in a situation that you have a local or corporate repository manager that you use as part of your daily software development process, and you only want to use Sonatype OSSRH on occasion. You can can configure this in your settings.xml, usually placed in ~/.m2, like this:




Normally when you run deploy, your artifacts will go to local-nexus (or whatever you configure), but when you want to use Sonatype OSS, you can just use

mvn deploy -P!local-repository

and Maven will deploy according to the <distributionManagement> defined in


The benefit of this method is that you do not have to put any local or unnecessary corporate information in the pom.xml you are distributing with your project.

Warning: some older versions of the maven-deploy-plugin do not support this properly, so use the latest version, for example, in your pom.xml:

          Bugs in older versions prevent altReleaseDeploymentRepository
          and altSnapshotDeploymentRepository from working correctly

  . . .