maven override project.version from command line

前端 未结 3 1300
长发绾君心
长发绾君心 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条回答
  •  -上瘾入骨i
    2021-01-30 21:27

    Simply you can't override project.version. Try:

    mvn versions:set -DnewVersion=
    

    Usually, I start by updating the parentPom

    mvn versions:set -DnewVersion=1.0.3-SNAPSHOT
    

    This would be enough if the parent pom contained all child projects if not you will need to go to a super project that contain all child project and execute

    mvn versions:update-child-modules
    

    Also the two previous steps will be enough if the parentPom exists in relative path if not you will need to install parentPom project with the new version

    mvn install
    

    Usually this will be enough if you don't have module depend on another module. if you do, declare its version as a project.version like that and it will be reflected automatically

    ${project.version}
    

    Check the maven Versions Plugin docs.

提交回复
热议问题