Reputation: 1013
What I am trying is to get the project version, project artifact-Id etc. from pom.xml.
I have started with just to print hello string through command line,
mvn --non-recursive org.codehaus.mojo:exec-maven-plugin:exec -Dexec.executable=CMD -Dexec.args='/C' -Dexec.args='ECHO' -Dexec.args='hello'
Somehow its not printing the string, any help is much appreciated.
My understanding was, below command should echo the project version but its not.
mvn --non-recursive org.codehaus.mojo:exec-maven-plugin:exec -Dexec.executable=CMD -Dexec.args='/C' -Dexec.args='ECHO' -Dexec.args='${project.version}'
Upvotes: 0
Views: 706
Reputation: 97409
There is a better solution.
mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version
That will print out the information with scattered other information. This can be improved by using the following:
mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout
If you have correctly define the version of the maven-help-plugin in your pom file this can be simplified like this:
mvn help:evaluate -Dexpression=project.version -q -DforceStdout
By using this you can access any kind of information within the pom file like artfaictId
, groupId
etc.
mvn help:evaluate -Dexpression=project.groupId -q -DforceStdout
I recommend to use the most recent version of Maven (3.5.4)..
Upvotes: 1