maven override project.version from command line

前端 未结 3 1302
长发绾君心
长发绾君心 2021-01-30 20:51

I wonder if it is possible to override project.version/version variable in maven via command line?

The following doesn\'t work:

mvn deploy -Dversion=1.         


        
3条回答
  •  日久生厌
    2021-01-30 21:39

    In Maven 3.5+, if you put the following in your pom.xml

    ${revision}
    ...
    
        1.0.0-SNAPSHOT
    
    

    it will use 1.0.0-SNAPSHOT by default, but you can override it on the command line:

    mvn -Drevision=2.0.0-SNAPSHOT clean package
    

    Apparently this only works if the placeholder property is called revision (you can also use changelist and sha1 placeholders in your version).

    See https://maven.apache.org/maven-ci-friendly.html

提交回复
热议问题