23

Is it possible to in some way tell the maven deploy:file goal to deploy to two independent artifactories based on whether the version of the project is a snapshot / release?

I'm hoping there might be a property which indicates the fact the version has -SNAPSHOT prepended, or perhaps the default artifactory to deploy to (which has been worked out based on the version number already).

I thought about using two different profiles and working out if its a snapshot in ant by parsing the pom.xml file, but I'd rather a cleaner solution if possible.

Currently, my deploy plugin looks as follows, but this just deploys to the release artifactory regardless of the version;

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-deploy-plugin</artifactId>
   <version>2.5</version>
   <executions>
      <execution>
        <id>deploy-zip-created-by-ant-to-artifactory</id>
    <phase>deploy</phase>
    <goals>
       <goal>deploy-file</goal>
    </goals>
    <configuration>
       <repositoryId>${project.distributionManagement.repository.id}</repositoryId>
       <url>${project.distributionManagement.repository.url}</url>
       <file>${project.basedir}/Build/deploy/MyArtifact.zip</file>
       <pomFile>${project.basedir}/MyArtifact-pom.xml</pomFile>
    </configuration>
      </execution>
   </executions>
</plugin>

Many Thanks

4

4 回答 4

9

如果您在 settings.xml 中定义了存储库,则可以使用

mvn deploy:deploy-file -DrepositoryId=releases -DartifactId=... -Durl=
于 2011-07-29T10:27:57.503 回答
5

这里,我使用 GMaven 插件从distributionManagementPOM 部分中选择存储库并将其存储在一个属性中。

然后部署插件可以使用该属性。

于 2012-11-30T12:38:45.720 回答
0

也许你想使用build-helper-maven-plugin来部署一个额外的工件

于 2013-02-04T11:03:38.967 回答
-3

这大概是Maven的方式:

  <distributionManagement>
    <repository>
      <id>release</id>
      <url>http://my-releases</url>
    </repository>
    <snapshotRepository>
      <id>snapshots</id>
      <url>http://my-snapshots</url>
    </snapshotRepository>
  </distributionManagement>

在部署快照版本时,它将进入快照存储库。对于非快照版本,将使用常规存储库。

只需运行 deploy 就可以了。:-)

于 2012-06-06T16:40:04.713 回答