Java – get POM. From commandline XML attribute

I am currently writing a script for our gitlab Ci, which will automatically upload files to the nfsshare folder on the network Since I want to organize builds and we are using maven, I think I can "easily" from POM XML to get the project name

Is there a way to get from POM. Com through command line tools or something Get attributes from XML? The only other way I can think of is "regular expression - getting value manually" - in my opinion, this is not a very clean solution

I've found the properties plugin, but it seems to be just through the actual Properties file to add new properties

Any help will be appreciated!

Solution

If you know the name of the desired attribute, you can get the value using the following values:

mvn help:evaluate -Dexpression=[property-name] | findstr /R ^^[^^\[INFO\]]

For example:

mvn help:evaluate -Dexpression=basedir | findstr /R ^^[^^\[INFO\]]

Will output:

C:\Users\nick\Local\Projects\example

This obviously assumes that you build on a Windows machine with findstr and delete all other log records made by Maven runtime You can do similar things with grep on UNIX, but I'll leave it to you

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>