user2544272
user2544272

Reputation: 35

deploying artifacts to two different repository

Currently in my project, I am deploying artifacts to central repository by providing the distribution management.

My requirement is when my pom version has got 1.0-SNAPSHOT - It should get deployed to libs-snapshot and when my pom version just has 1.0 in it, it should get deployed to libs-release.

Basically, it should deploy based on the version that i provide with or without snapshot and respective repositories.

Please help me how can I configure to deploy my maven projects to two different repositories and configuring in settings.xml.

Thanks in advance

Upvotes: 0

Views: 643

Answers (1)

Behe
Behe

Reputation: 7940

You can specify two repositories in the distribution management section. One for the releases and one for the snapshots. Depending on your version number, the corresponding repository should be used for distribution.

You can't configure this setting in settings.xml, you have to configure it in the pom.xml. See this link

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
  ...
  <distributionManagement>
    <repository>
      <uniqueVersion>false</uniqueVersion>
      <id>corp1</id>
      <name>Corporate Repository</name>
      <url>scp://repo/maven2</url>
      <layout>default</layout>
    </repository>
    <snapshotRepository>
      <uniqueVersion>true</uniqueVersion>
      <id>propSnap</id>
      <name>Propellors Snapshots</name>
      <url>sftp://propellers.net/maven</url>
      <layout>legacy</layout>
    </snapshotRepository>
    ...
  </distributionManagement>
  ...
</project>

Example taken from POM Reference - Distribution_Management section, where you can find more information about it.

If you want to share the distribution management section for multiple projets, this answer shows a way to specify it company wide by using a pom packaged parent project.

Upvotes: 1

Related Questions