Set the version of a dependency from command line

北城余情 提交于 2020-05-23 10:31:26

问题


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.

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.


回答1:


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

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

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.



来源:https://stackoverflow.com/questions/57788881/set-the-version-of-a-dependency-from-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!