Maven版本:准备与pom非交互 [英] Maven release:prepare-with-pom non-interactive

查看:265
本文介绍了Maven版本:准备与pom非交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试与Maven发布一个项目.

I'm trying to release a project with Maven.

我的项目POM包含-SNAPSHOT依赖项,因此为了自动执行发布,我想基于"maven-release-plugin"目标使用以下maven命令:mvn release:prepare-with-pom为了准备项目的pom.xml,用于自动释放和解决依赖项-SNAPSHOT版本,而无需手动编辑它们.

My project POM is containing -SNAPSHOT dependencies, so in order to perform the release automatically, I want to use the following maven command, based on the "maven-release-plugin" goals: mvn release:prepare-with-pom in order to prepare the project's pom.xml for releasing and resolve dependencies -SNAPSHOT versions automatically without edit them by hand.

不幸的是,我发现这仅在命令行的交互模式下有效.我的想法是,我想知道是否可以在没有任何手动交互的情况下完成此操作.我正在使用Bamboo作为CI服务器,并且希望将其纳入计划并自动执行该项目的发布. --non-interactive-B参数不起作用,实际上,如果我使用-B--non-interactive参数,则maven目标将失败.

Unfortunately I found this is working only in interactive mode from command line. The idea is that I'm wondering if this can be done without any manual interaction. I am using Bamboo as CI Server and I want to have this into a plan and perform this project releasing automatically. The --non-interactive or -B argument isn't working, actually if I'm using -B or --non-interactive argument the maven goal is failing.

这是mvn release:prepare-with-pom的输出:

H:\APPS\dev\cmtest\test-dependency\trunk>mvn release:prepare-with-pom -DdryRun=t
rue
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building test-dependency 0.0.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.0:prepare-with-pom (default-cli) @ test-depend
ency ---
[INFO] Resuming release from phase 'check-dependency-snapshots'
[INFO] Checking dependencies and plugins for snapshots ...
There are still some remaining snapshot dependencies.: Do you want to resolve th
em now? (yes/no) no: : yes
Dependency type to resolve,: specify the selection number ( 0:All 1:Project Depe
ndencies 2:Plugins 3:Reports 4:Extensions ): (0/1/2/3) 1: : 1
Resolve Project Dependency Snapshots.: '${artifactGroup}:${artifactId}' set to releas
e? (yes/no) yes: : yes
What is the next development version? (0.1.3-SNAPSHOT) 0.1.3-SNAPSHOT: :
'${artifactGroup}:${artifactId1}_1' set to release? (yes/no) yes: : yes
What is the next development version? (0.0.2-SNAPSHOT) 0.0.2-SNAPSHOT: :
'${artifactGroup}:parent-pom' set to release? (yes/no) yes: : yes
What is the next development version? (0.0.3-SNAPSHOT) 0.0.3-SNAPSHOT: :
What is the release version for "test-dependency"? (${artifactGroup}:${artifactId1}_2) 0.0.4: :
What is SCM release tag or label for "test-dependency"? (${artifactGroup}:${artifactId1}_2) test-dependency-0.0.4: :
What is the new development version for "test-dependency"? (${artifactGroup}:${artifactId1}_2) 0.0.5-SNAPSHOT: :
[INFO] Transforming '${artifactId1}_2'...
[INFO] Updating ${artifactId1}_1 to 0.0.1
[INFO] Updating ${artifactId1} to 0.1.2
[INFO] Generating release POMs...
[INFO] Generating release POM for 'test-dependency'...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

那么,您能帮我找到一个窍门,以便在非交互模式下执行此maven命令吗? 非常感谢

So, can you help me please to find a trick in order to perform this maven command in non-interactive mode? Thanks a lot

推荐答案

虽然您的pom指的是快照版本,但我认为非交互性是不可能的(也许是花哨的期望"脚本,但可能有点多)

While your pom refers to snapshot releases I don't believe non-interactive is possible (maybe a fancy 'expect' script but that might be a bit much).

释放依赖快照的库非常危险,因为这些库可能会在您的脚下改变.任何使用您的库的人都会假设,每次使用它们时,它们都将获得相同的jar,相同的SHA,但实际上并非如此.这就是为什么maven几乎不可能做到这一点.

Releasing a library that relies on snapshots is very dangerous because the libraries can change from under your feet. Anyone using your library is going to assume that every time they use it they're getting the same jars, with the same SHAs, but in reality that's not the case. That's why maven makes it nearly impossible do to this.

我建议集中精力将依赖项移至已发布的版本,或者,如果这不是一种选择,请将您的库保留为快照.将您的库保留为快照意味着您的客户至少知道他们使用的库可能会在他们不知情的情况下发生更改.

I'd recommend concentrating on moving your dependencies to released versions, or if that's not an option, keeping your library as a snapshot. Keeping your library as a snapshot means that your clients are at least aware that the libraries they're using can change without their knowledge.

这篇关于Maven版本:准备与pom非交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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