如何仅将pom文件部署到Maven中的快照存储库? [英] How can I deploy only the pom file to my snapshot repository in Maven?

查看:330
本文介绍了如何仅将pom文件部署到Maven中的快照存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当运行mvn deploy并且版本是SNAPSHOT版本时,我只希望部署POM项目(文件)而没有主要项目(JAR,WAR等).

I would like to be able to deploy only the POM artifact (file) without the main artifact (JAR, WAR, etc), when running mvn deploy and version is a SNAPSHOT version.

为什么?

我们有几个开发人员致力于多个Maven项目.我们有一个Hudson服务器,每个Maven项目和版本都有一个工作(例如foo-1.2,foo-1.3).每个作业都会构建项目,并将其部署到Nexus服务器(成功时).通过使用版本中的-SNAPSHOT后缀将正在开发的Maven项目标记为此类.例如:1.2-快照,1.3-快照.

We several developers working on multiple Maven projects. We have a Hudson server with a job per Maven project and version (e.g. foo-1.2, foo-1.3). Each job builds the project and deploys it to a Nexus server (upon success). Maven projects under development are marked as such by using -SNAPSHOT postfix in the version. For example: 1.2-SNAPSHOT, 1.3-SNAPSHOT.

这是一个示例场景,该架构如何破坏开发人员的工作.

Here's a sample scenario how a developer work is damaged due to this architecture.

假设有两个Maven项目:foo-core和foo-webapp,两者的版本均为1.2-SNAPSHOT.

Assume two Maven projects: foo-core and foo-webapp, both at version 1.2-SNAPSHOT.

  • 开发人员A正在研究foo-core,进行了一些更改并进行了编译.
  • 开发人员A继续工作,但是可以在foo-webapp上使用.
  • 开发人员B开始工作并更改foo-core.它会提交他的工作并将其推送到SCM.
  • Hudson由SCM触发;构建foo-core,并将其部署到Nexus中的快照存储库中.
  • 开发人员A在foo-webapp上运行mvn install. Maven正在检查Nexus,发现Nexus中有较新版本的foo-core.由于开发人员A所做的更改不在本地存储库中的jar中,因此它下载了该文件(充满了开发人员B的更改),然后编译失败.下载内容将覆盖开发人员A在此处安装的文件.
  • Developer A is working on foo-core, made several changes and compiled it.
  • Developer A continues to work, but on foo-webapp.
  • Developer B started working and changing foo-core. It commits his work and pushes it to the SCM.
  • Hudson is triggered by SCM; Builds foo-core and deploys it to the snapshot repository in Nexus.
  • Developer A is running mvn install on foo-webapp. Maven is checking with Nexus, and finds that there is a newer version of foo-core in Nexus. It downloads it (filled with developer B changes) and than it fails compilation, since the changes made by developer A are not in the jar located in the local repository. The download overrides the file installed there by developer A.

现有解决方案

我研究了maven-deploy-plugin,但是此插件部署了附加到项目的所有工件.如果他们能够配置要部署的工件,那就太好了.

I looked into maven-deploy-plugin, but this plugin deploys all artifacts attached to the project. If they had a way to configure which artifacts to deploy, it would have been great.

问题:有什么方法可以解决这个问题,而无需借助基于maven-deploy-plugin编写自己的deploy插件?

Question: Is there any way to solve this without resorting to writing my own deploy plugin, based on maven-deploy-plugin?

推荐答案

基本上,将pom.xml传递给-Dfile参数,而不是工件,传递pom.xml,但是仅仅这样做是不够的.您还需要提供项目的参数-DgroupId-DartifactId.运行命令,然后开始! mvn deploy现在不会给您任何问题.这是一个示例部署命令:

Basically to the -Dfile parameter, instead of the artifact, pass the pom.xml, but just doing this is not enough. You'll also need to supply the parameters -DgroupId and -DartifactId of the project. Run the command and yay! mvn deploy won't give you any issues now. Here's a sample deploy command :

$ mvn deploy:deploy-file -DpomFile=pom.xml -Dfile=./pom.xml -DgroupId=my.group.id -DartifactId=artifact-id -DrepositoryId=bigdata-upload-snapshots -Durl=http://maven.mymaven.com/content/repositories/snapshots/

先决条件是将存储库添加到您的settings.xml中.

A prerequisite for this is that the repository be added in your settings.xml

这篇关于如何仅将pom文件部署到Maven中的快照存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆