Multiple deployments in maven

Mauli picture Mauli · Mar 11, 2009 · Viewed 13.5k times · Source

We have a internal artifactory repository. At the moment all snapshots will be deployed there. We also want to have a different server with a web interface, and want to copy the to it the created artifacts.

For our builds we use Hudson, but the post-build action "Deploy artifacts to Maven repository" together with scp doesn't work. So there is the question of doing it in some other elegant way. Why isn't maven able to have several distribution repositories? Any ideas?

The nicest thing would be if artifactory would support an (automatic!) incremental export to a standard maven repository after each new deployment.

Answer

jon077 picture jon077 · Mar 13, 2009

I don't think maven supports deploying to multiple repositories for a single profile, but perhaps profiles could change the id and urls of the repository.

  <distributionManagement>
    <repository>
      <id>${repo-id}</id>
      <name>${repo-name}</name>
      <url>${repo-url}</url>
    </repository>
  </distributionManagement>

Maven Deployment

Then use profiles to pick which repo to deploy to:

<profiles>
  <profile>
    <id>repo1</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    <properties>
      <repo-id>repo1</repo-id>
      <repo-name>Repo1 Name </repo-name>
      <repo-url>http://url.com/maven2</repo-url>
    </properties>
  </profile>
  <profile>
    <id>repo2</id>
    <properties>
      <repo-id>repo2</repo-id>
      <repo-name>Repo2 Name </repo-name>
      <repo-url>http://url2.com/maven2</repo-url>
    </properties>
  </profile>
</profiles>

Maven profiles