[转] Maven 从命令行获取项目的版本号
【From】https://blog.soebes.de/blog/2018/06/09/help-plugin/
I bet you have been faced with the situation to get the version of your Maven project on command line? So the question is how to get it? I have seen many solutions via using Linux tools like grep
, cat
or awk
etc. also seen many solutions like using exec-maven-plugin like this:
1 |
|
Unfortunately the above approach will not work on Windows.
Starting with Maven Help Plugin Release 3.1.0 this can be done more easier like the following:
1 |
|
This will exactly print out the version of your artifact on stdout and nothing else. Also no line feed is printed out.
So this can be used easily in scripts like this:
1 |
|
If you have correctly pinned the version of your plugins in your pom file or in a parent pom of the project this can be simplified like this:
1 |
|
Apart from extracting the version you can also extract other information from the pom file like the following:
1 |
|
More sophisticated expressions like the following are possible too:
1 |
|
Posted by Karl-Heinz Marbaise Jun 9th, 2018 Maven, Maven-Plugins, Usage
最新文章
- WebService入门
- javax.el.PropertyNotFoundException 出错
- mount: unknown filesystem type 'ntfs'
- iOS sha1加密算法
- 通过url给action传中文参数乱码解决方案
- python爬虫从入门到放弃(一)之初识爬虫
- C++学习-8
- 2. 引入springmvc
- windows service创建使用整合
- CIA402状态转换图
- FTP软件FileZilla 3.38.1下载
- 理解UDP协议的首部校验和校验和
- winserver2012 下安装 sqlserver2008
- Memcached cas 陷阱
- ehcache讲解及实例
- php 页面调转导致session丢失解决方法
- 使用Solrj 获取语句分词结果的代码
- math模块
- drupal pathauto的配置
- .NET中的六个重要概念