Maven - (Deploy|Distribution) Phase


This deploy phase copies:

  • a (final) package
  • or the Javadoc documentation

to a remote repository for sharing with other developers and projects.

In most project builds, the deploy phase of the build lifecycle is implemented using the deploy:deploy mojo

See also: the install phase to install your software in a local repository.


The whole configuration is done in the pom.xml file

Define the plugin version

    <!-- To define the plugin version in your parent POM -->
    <!-- To use the plugin goals in your POM or parent POM -->

Define the (remote) repository in distributionManagement

To enable the deploy plugin to function, a valid <distributionManagement/> in the pom.xml must be included with:

	  <name>Repository name</name>
	  <url>Host to Company Repository</url>
          <name>Snapshot Repository name (For instance: Internal Release)</name>
          <name>my Site Name</name>

Url follows the URI specification and specifies both the transport protocol (scheme) and the location to be used to transfer a built artifact

Add a file transfer method (connector)

Maven Wagon is a file (transfer|transport) application with modules (FTP, SSH, …)

For SSH (scp, sftp), you need to use the following module:

      <!-- Enabling the use of SSH -->


deploy a build artifact

In most cases, the deploy mojo is invoked when you call the deploy phase of the default build lifecycle.

mvn deploy

deploy a third party artifact

Artifacts which are not built using Maven can be added to any remote repository using the deploy-file.

mvn deploy:deploy-file -Durl=file://C:\m2-repo \   (or scp://
                       -Dfile=your-artifact-1.0.jar \
                       [-DpomFile=your-pom.xml] \
                       [] \
                       [-DartifactId=your-artifact] \
                       [-Dversion=1.0] \
                       [-Dpackaging=jar] \
                       [-Dclassifier=test] \
                       [-DgeneratePom=true] \
                       [-DgeneratePom.description="My Project Description"] \
                       [-DrepositoryLayout=legacy] \


  • URL where the artifact will be deployed. Example:
    • file:///C:/m2-repo for a local repository
    • or scp:// for a remote repository. You need to add the ssh extension
  • repositoryId default to remote-repository. Define in settings.xml. See Maven - (Remote Repository|Server)
  • the groupId, artifactId, version and packaging informations are automatically retrieved from the given pom.

Documentation / Reference

Powered by ComboStrap