Difference between altDeploymentRepository and altReleaseDeploymentRepository

Lionel Briand picture Lionel Briand · Jan 12, 2017 · Viewed 8.1k times · Source

I use swagger to generate web services clients on my project. The generated code produce a library that can be use as a Maven lib. I already successfully deploy release version into my private sonatype-nexus.

I wonder what is the difference between altDeploymentRepository and altReleaseDeploymentRepository? How mvn deploy select which repository to use if the two parameters are set?

As the apache-maven deploy documentation said :

altDeploymentRepository: Specifies an alternative repository to which the project artifacts should be deployed ( other than those specified in ). Format: id::layout::url

altReleaseDeploymentRepository: The alternative repository to use when the project has a final version.

altSnapshotDeploymentRepository: The alternative repository to use when the project has a snapshot version.

What exactly does

when the project has a final version.

mean?

Answer

Tunaki picture Tunaki · Jan 12, 2017

When altReleaseDeploymentRepository is specified, it is always used when the project has a release (or "final") version, i.e. is not a snapshot version. When altSnapshotDeploymentRepository is specified, it is always used when the project has a snapshot version. altDeploymentRepository is a default alternate deployment repository when none of the above repository were specified or used.

So to put it another way, if you have a release version, then:

  • altReleaseDeploymentRepository will be used if specified;
  • otherwise altDeploymentRepository will be used if specified;
  • otherwise the release remote repository declared in the <distributionManagement><repository> POM element will be used if specified;
  • otherwise the plugin will error because it didn't find any remote repository to deploy to.

Similarly, if you have a snapshot version, then:

  • altSnapshotDeploymentRepository will be used if specified;
  • otherwise altDeploymentRepository will be used if specified;
  • otherwise the snapshot remote repository declared in the <distributionManagement><snapshotRepository> POM element will be used if specified;
  • otherwise the release remote repository declared in the <distributionManagement><repository> POM element will be used if specified;
  • otherwise the plugin will error because it didn't find any remote repository to deploy to.