2

There is the same question answered for Linux - How to get Maven project version to the bash command line

But what about Windows?

Community
  • 1
  • 1
Igor Mukhin
  • 15,014
  • 18
  • 52
  • 61

1 Answers1

9

Worked for me in command line:

mvn -q --non-recursive "-Dexec.executable=cmd" "-Dexec.args=/C echo ${project.version}" "org.codehaus.mojo:exec-maven-plugin:1.3.1:exec"

In a batch file:

for /f %%i in ('call mvn -q --non-recursive "-Dexec.executable=cmd" "-Dexec.args=/C echo ${project.version}" "org.codehaus.mojo:exec-maven-plugin:1.3.1:exec"') do set PVERSION=%%i
echo %PVERSION%
Igor Mukhin
  • 15,014
  • 18
  • 52
  • 61