简体   繁体   English

mvn deploy:文件到不同的存储库以获取快照和发布版本

[英]mvn deploy:file to different repositories for snapshot and release version

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? 是否有可能以某种方式告诉maven部署:文件目标是根据项目的版本是快照/发布来部署到两个独立的工件?

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). 我希望可能有一个属性表明该版本具有-SNAPSHOT前置的事实,或者可能是要部署到的默认工件(已经根据版本号计算出来)。

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. 我想过使用两个不同的配置文件,并通过解析pom.xml文件来解决它在ant中的快照,但如果可能的话,我宁愿使用更干净的解决方案。

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 非常感谢

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

mvn deploy:deploy-file -DrepositoryId=releases -DartifactId=... -Durl=

Over here , I used the GMaven plugin to choose the repository from the distributionManagement section of the POM and store it in a property. 这里 ,我使用GMaven插件从POM的distributionManagement部分选择存储库并将其存储在属性中。

The deploy plugin can then use that property. 然后,部署插件可以使用该属性。

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

This is presumably the Maven way: 这可能是Maven的方式:

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

When doing a deploy of a snapshot version, it'll go the snapshots repository. 在部署快照版本时,它将进入快照存储库。 For a non-snapshot release the regular repository will be used. 对于非快照版本,将使用常规存储库。

Just run deploy and it'll work. 只需运行部署就可以了。 :-) :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 mvn release:perform不部署发行版 - mvn release:perform doesn't deploy release version mvn release:perform生成SNAPSHOT吗? - mvn release:perform generate a SNAPSHOT ? 为什么mvn release:perform总是创建一个新的快照版本并将其上传到存储库而不是非快照版本? - Why does mvn release:perform always create a new snapshot version and upload that to the repository instead of the non-snapshot release version? 在没有SNAPSHOT版本的发布版本之后部署Jenkins站点作业 - Deploy Jenkins site job after Release build without SNAPSHOT version 在 mvn 发布期间使用 mvn 版本插件 - Use mvn version plugin during mvn release mvn release plugin发布下一个快照而不是当前版本 - mvn release plugin releasing next snapshot not current release 为什么Maven(不正确?)将SNAPSHOT部署到发布和快照存储库中? - Why is Maven (incorrectly?) deploying my SNAPSHOT to both the release and snapshot repositories? 在Maven中,如何在发行版中命名与在快照构建中不同的war文件 - In maven, how to name war file different in release than in snapshot build mvn release:prepare 不更新父版本 - mvn release:prepare does not update parent version 有没有办法列出 mvn-deploy 来发布工件存储库? - Is there a way to List mvn-deploy to publish artifact repositories?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM