Install and Deploy

If you want to share your built artifacts between projects, you can use two other tasks: install for installing them in your local repository for access as dependencies in other scripts, and deploy for deploying them to a remote location you have set up to serve as a repository in your organisation.

Note: that the installation and deployment require that you have a Maven 2.0 POM file to deploy along with it. These are required for the transitive dependency mechanism to work effectively, and can be quite simple to create.

The following example shows basic use of the install and deploy tasks.

...
  <artifact:pom id="mypom" file="pom.xml" />

  <artifact:install file="target/my-project-1.0.jar">
    <pom refid="mypom"/>
  </artifact:install>

  <artifact:deploy file="target/my-project-1.0.jar">
    <remoteRepository url="file:///www/repository"/>
    <pom refid="mypom"/>
  </artifact:deploy>
...

Attaching Multiple Artifacts

The install and deploy tasks allow you to attach multiple artifact to a single deployment. For example, the sources and javadoc jars can be attached using the nested attach element.

  <artifact:deploy file="target/my-project-1.0.jar">
    <remoteRepository url="http://localhost/www/repository"/>
    <pom refid="mypom"/>
    <attach file="${basedir}/target/my-project-1.0-sources.jar" type="jar" classifier="sources"/>
    <attach file="${basedir}/target/my-project-1.0-javadoc.jar" type="jar" classifier="javadoc"/>
    <attach file="${basedir}/target/my-project-1.0-junk.zip" type="zip" classifier="junk"/>
  </artifact:deploy>

Deployment Protocols

For deploying using a protocol other than local file system, you need to register a provider to make the other protocols available. For example:

...
  <artifact:install-provider artifactId="wagon-ssh" version="1.0-beta-2"/>

  <artifact:deploy file="target/my-project-1.0.jar">
    <remoteRepository url="scp://localhost/www/repository">
      <authentication username="${repository.username}" privateKey="${user.home}/.ssh/id_dsa"/>
    </remoteRepository>
    <pom refid="mypom"/>
  </artifact:deploy>
...

Note: that if you use antcall, the provider isn't available during the Ant call: you have to register it again if you need it.

Maven Ant Tasks contain wagon-file and wagon-http-lightweight providers. Some other available providers are:

Protocol Artifact ID
http wagon-http
scp wagon-ssh
scpexe wagon-ssh-external
ftp wagon-ftp
webdav wagon-webdav

Other providers and the current versions of each can be found at http://maven.apache.org/wagon/