Code Snippet

Just another Code Snippet site

[Maven] How-to

Evaluate pom’s property from command line :

POM_VERSION=`mvn help:evaluate -Dexpression=project.version -N | grep -v INFO | grep -v WARNING | grep -v Download`

Evaluate pom’s property from command line :

POM_VERSION=`mvn -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`

to remove ‘-SNAPSHOT’ in bash :

export BASE_VERSION="${POM_VERSION/'-SNAPSHOT'/}"


2 thoughts on “[Maven] How-to

  • Olivier says:

    Download a file from repo :

    mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get \
    -DrepoUrl=http://REPO_URL/ \
    -Ddest=./DESTINATION_FILE.jar \
    -Dtransitive=false \
    -Dartifact=GROUP_ID:ARTIFACT_ID:VERSION:PACKAGING
    
  • Enable JaCoCo repor from CLI (without changing pom):

    mvn org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report -Dmaven.test.failure.ignore=true
    

Leave a Reply

Your email address will not be published. Required fields are marked *