从脚本更新Maven项目版本 [英] Update a Maven project version from script

查看:120
本文介绍了从脚本更新Maven项目版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我有一些理解,以下可能不是普遍接受的做事情的方式。

First of all, I do have some sort of understanding that the following might not be the generally accepted way to do things.

我们有一个Maven 2项目有一个版本号,应该在每个新版本中每周更新一次。在这个过程中,我试图消除所有的事情,一个人记住,我做了一个bash脚本,以交互方式处理的过程。

We have a Maven 2 project that has a version number which should be updated each week or so, during a new release. During this process, I've tried to eliminate all the things one has to remember and I've made a bash script that handles the process interactively.

但是,我的问题正在从命令行更新pom版本。我可以用sed这样做,但我不认为这是非常方便。我想知道是否有任何maven插件,将能够直接从命令行修改pom.xml。版本在pom的属性部分中设置。是否可以编写一个可以改变属性的插件?

However, my problem is updating the pom version from the command line. I can do this with sed but I don't think it is very convenient. I was wondering if there is any maven plugin that would be able to modify the pom.xml directly from the command line. The version is set in the properties section of the pom. Would it be possible to write a plugin that would change the properties?

提前感谢。

更新

似乎我的问题是项目版本定义为属性(过滤时应用),现在看起来有点蠢。

It seems that my issue was with project versions defined as properties (that were applied when filtering) which seems now a bit dumb.

我仍然在寻找答案的一件事是如何获得某个项目的版本可靠地到命令行。以前我有一个非常独特的属性,我使用 grep ,但现在< version> 元素不是唯一的在子项目中至少有两个。如果Maven没有解决方案,我需要某种XML解析器,但我的目标是使脚本尽可能独立。

One thing that I'm still looking for an answer is how to get the version of certain project reliably to the command line. Previously I had a "pretty unique" property that I got using grep, but now the <version> element is not unique as in child project there is at least two of these. I would need some sort of XML parser if Maven has no solutions, but my goal is to make the script as independent as possible.

我不知道从这创造了一个新的问题,但我没有。获取版本与设置版本非常相关。

I'm not sure if I should've created a new question from this, but I didn't. Getting the version is very closely related to the setting the version.

推荐答案


是任何可以直接从命令行修改pom.xml的maven插件。

I was wondering if there is any maven plugin that would be able to modify the pom.xml directly from the command line.

版本Maven插件可以做到这一点。检查以下目标:

The Versions Maven Plugin can do this. Check the following goal:


  • versions:set 可以用于从命令行设置项目版本,更新任何子项的详细信息必要的模块。

这篇关于从脚本更新Maven项目版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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