-
-
Save loverdos/99bbd34097b8a00f52be to your computer and use it in GitHub Desktop.
mvn help:evaluate -Dexpression=project.version | grep -e '^[^\[]' |
grep version pom.xml | grep -v -e '<?xml|~'| head -n 1 | sed 's///' | sed 's/</version>//'| awk '{print $1}'
Hi,
This is what I'm getting with May 21's version:
sed: -e expression #1, char 14: unknown option to `s'
sed: -e expression #1, char 0: no previous regular expression
I have the same error
$ grep version pom.xml | grep -v -e '<?xml|~'| head -n 1 | sed 's///' | sed 's///'| awk '{print $1}'
sed: -e expression #1, char 14: unknown option to `s'
sed: -e expression #1, char 0: no previous regular expression
small improvement
grep version pom.xml | grep -v -e '<?xml|~'| head -n 1 | sed 's/[[:space:]]//g' | sed -E 's/<.{0,1}version>//g' | awk '{print $1}'
Latest version maven help plugin makes it even more easy.
mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout
@KalivarapuReshma Thanks for that command, I have used it to create this Docker Hub hook script to tag Maven projects with their version
Grepping in POM does not honor maven core plug-ins that may alter the version at runtime (e.g. git branch versioning plug-in). So https://gist.github.com/loverdos/99bbd34097b8a00f52be#gistcomment-2721978 looks like the best solution to me.
mvn help:evaluate -Dexpression=project.version | grep -v '^['