从命令行设置依赖项的版本 [英] Set the version of a dependency from command line

查看:194
本文介绍了从命令行设置依赖项的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从命令行在POM中设置依赖项的版本.与versions:set非常相似(对于项目的版本),但是具有特定的依赖性.

I would like to set the version of a dependency in a POM from command line. Much like versions:set (for the version of the project), but for a specific dependency.

我不想制作任何XML扫描工具,因为有多种方法可以指定版本,并且很难全部处理.

I don't want to craft any XML scanning tool because there are various ways to specify a version and it is hard to handle them all.

推荐答案

如果您知道在dependencydependencyManagement博客中指定了依赖版本,并且该版本不是属性,则可以使用

If you know your dependency versions are specified in the dependency or dependencyManagement blog and the version is not a property you can use use-dep-version:

mvn versions:use-dep-version -Dincludes=io.netty:netty-all -DdepVersion=1.0 -DforceVersion=true

但是,如果将版本指定为属性,则use-dep-version将不起作用.

However if the version is specified as a property, the use-dep-version will not work.

然后,您只能使用versions:*-property命令,但是为此您需要知道属性的名称(可以通过对这些属性使用命名约定来实现)

Then you can only use versions:*-property commands but for this you need to know the name of the property (which could be achieved by having a naming convention for these properties)

mvn versions:set-property -DnewVersion=1.0 -Dproperty=netty-all.version

如果您需要更多安全性以确保将使用的版本有效或避免降级,请查看

if you need more safety that the version you will use is valid or to avoid downgrades have a look at update-property.

如果您的项目中混有版本和属性版本,则可以只运行两个命令,一个将对其进行更改.

If you project is mixed with versions and property versions you could just run both commands and one will change it.

这篇关于从命令行设置依赖项的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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