maven项目版本管理

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ZYC88888/article/details/88174486

当前项目有许多模块并且存在父子关系,如下:

    <parent>
        <groupId>com.boot</groupId>
        <artifactId>boot-facede</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
    <artifactId>boot-facede-flat</artifactId>
    <packaging>jar</packaging>


执行以下命令,升级父项目以及所有子项目的版本:

mvn versions:set -DnewVersion=2.0.0-SNAPSHOT


得到以下结果

  <parent>
        <groupId>com.boot</groupId>
        <artifactId>boot-facede</artifactId>
        <version>2.0.0-SNAPSHOT</version>
    </parent>
    <artifactId>boot-facede-flat</artifactId>
    <packaging>jar</packaging>

如果想回退:

mvn versions:revert

revert  rely on the 

pom.xml.versionsBackup


接下来修改所有被依赖的版本:

mvn versions:update-child-modules

或者

mvn ‐N versions:update‐child‐modules

确认变更 

mvn versions:commit

 查看更新组件

mvn versions:display-plugin-updates


当项目开发到一定阶段要切换为正式版本时,则执行以下命令:

mvn release:prepare
 <parent>
        <groupId>com.boot</groupId>
        <artifactId>boot-facede</artifactId>
        <version>2.0.0-RELEASE</version>
    </parent>
    <artifactId>boot-facede-flat</artifactId>
    <packaging>jar</packaging>


要发布正式版本时则执行以下命令:

mvn release:perform


更多详细官方文档:http://www.mojohaus.org/versions-maven-plugin/usage.html

http://www.mojohaus.org/versions-maven-plugin/examples/set.html

猜你喜欢

转载自blog.csdn.net/ZYC88888/article/details/88174486
今日推荐