如何从Shell脚本中的pom.xml文件提取GAV [英] How to extract the GAV from a pom.xml file in a shell script

查看:301
本文介绍了如何从Shell脚本中的pom.xml文件提取GAV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从大量的pom.xml文件中提取Maven GAV(groupId,artifactId,版本).并非所有POM都有父POM声明,因此需要考虑父GAV和项目GAV之间的继承.

I need to extract the Maven GAV (groupId, artifactId, version) from a large number of pom.xml files. Not all of the POMs have a parent POM declaration, so the inheritance between parent GAV and project GAV needs to be taken into account.

我只想使用可以在linux shell中轻松编写脚本的工具,例如重击.

I'd only like to use tools that can be easily scripted in a linux shell, e.g. bash.

推荐答案

grep -v '\[' <( mvn help:evaluate -Dexpression="project.groupId" 2>/dev/null && 
    mvn help:evaluate -Dexpression="project.artifactId" 2>/dev/null && 
    mvn help:evaluate -Dexpression="project.version" 2>/dev/null )

这篇关于如何从Shell脚本中的pom.xml文件提取GAV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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