title: maven: deploy dependencies to alternate repository
body: <p>Im trying to do something of a build promotion setup with our maven build.  Im doing this myself because the repository managers I've found dont quite fit the bill.</p>
  
  <p>I want the process to work like this:<br>
  1. Development deploys ear and jar files to the 'dev' repository<br>
  2. The build team runs a build to grab those file, adds QA specific configuration templates,  packages the result into a zip file<br>
  3. Using the <code>&lt;altDeploymentRepository&gt;</code> option, the build team deploys the zip file to the QA repository<br>
  4. Deploy the dependent ear and jar files to the QA repository
  5. After the QA cycle completes, the build team runs a build to download the (now tested) jar and ear files, add preprod specific configuration templates, and packages the result into a zip file<br>
  6. Using the <code>&lt;altDeploymentRepository&gt;</code> option, the build team deploys the zip file to the Preprod repository<br>
  ... and repeat the process again for production roll-out</p>
  
  <p>Everything works fine until step 4.  There doesn't seem to be a way to tell maven to deploy the <strong>dependencies</strong> to the alternate location.</p>
  
  <p>So the end result is how do I get the <strong>dependent</strong> ear and jar files copied between repositories, and do so in such a way that the version information is intact and I can run regular builds against the them.</p>
  
  <p>Switching of source and target repositories is done via a maven profile:</p>
  
  <pre><code>&lt;profile&gt;
    &lt;id&gt;qa&lt;/id&gt;
    &lt;distributionManagement&gt;
      &lt;repository&gt;
        &lt;id&gt;prddeploy&lt;/id&gt;
        &lt;name&gt;build server repository&lt;/name&gt;
        &lt;url&gt;${repoHost}/dev_repo&lt;/url&gt;
      &lt;/repository&gt;
    &lt;/distributionManagement&gt;
    &lt;build&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-deploy-plugin&lt;/artifactId&gt;
          &lt;configuration&gt;
           &lt;altDeploymentRepository&gt;qadeploy::default::${repoHost}/qa_repo&lt;/altDeploymentRepository&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  &lt;/profile&gt;
  </code></pre>
  
  <p>Where the 'dev' profile is the default so development needs no special steps, they just run <code>mvn deploy</code>.  The build team runs: <code>mvn deploy -P qa</code>  to start the qa deployment cycle.  </p>
  
  <p>I've tried using both nexus and artifactory as repository managers.  It doesn't seem to matter which one I use, but both are available if one or the other will make this process easier.  </p>
  
  <p>I know nexus offers a build promotion feature in its pro version, but based on the documentation the key deal breaker is that the staged repositories have to be <code>closed</code> before they can be used.  Our software has many different components and when fixing a bug in QA, we need to be able to redeploy only the changed components, and not the whole system.  The nexus staged repository setup doesn't seem to allow this.  If I'm reading it wrong, somebody please point me in the right direction.</p>