mvn部署:将快照和发布版本文件存储到不同的存储库
是否可以以某种方式告诉 Maven 部署:文件目标根据项目的版本是否是快照/发布来部署到两个独立的工件?
我希望可能有一个属性表明该版本已预先添加 -SNAPSHOT,或者可能是要部署到的默认工件(已根据版本号确定)。
我考虑过使用两个不同的配置文件,并通过解析 pom.xml 文件来确定它是否是 ant 中的快照,但如果可能的话,我宁愿采用更干净的解决方案。
目前,我的部署插件如下所示,但这只是部署到发布工件,无论版本如何;
<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>
非常感谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您在
settings.xml
中定义了存储库,则可以使用If you defined your repositories within your
settings.xml
you can use the在这里,我使用 GMaven 插件从 POM 的
distributionManagement
部分选择存储库并将其存储在属性中。然后部署插件可以使用该属性。
Over here, I used the GMaven plugin to choose the repository from the
distributionManagement
section of the POM and store it in a property.The deploy plugin can then use that property.
也许您想使用 build-helper-maven-plugin 进行部署额外的工件
Maybe you want to use the build-helper-maven-plugin to deploy an additional artifact
这可能是 Maven 方式:
在部署快照版本时,它将进入快照存储库。对于非快照版本,将使用常规存储库。
只需运行部署即可。 :-)
This is presumably the Maven way:
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. :-)