Maven版本控制

王守钰 2020-02-27 12:02:31

版本号设置

设置版本号
mvn versions:set -DnewVersion=1.0.0-SNAPSHOT
更新子项目依赖版本号
mvn versions:update-child-modules
提交申请
mvn versions:commit
版本回滚
mvn versions:revert

SCM插件

<scm>
    <connection>scm:git:项目git地址</connection>
    <developerConnection>scm:git:项目git地址</developerConnection>
    <url>项目预览地址</url>
    <tag>HEAD</tag>
</scm>
例:
<scm>
    <connection>scm:git:https://gitee.com/wxquan/xx.git</connection>
    <developerConnection>scm:git:https://gitee.com/wxquan/xx.git</developerConnection>
    <url>https://gitee.com/wxquan/xx</url>
    <tag>HEAD</tag>
</scm>

maven-realase-plugin插件

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.5.3</version>
    <configuration>
        <tagNameFormat>v@{project.version}</tagNameFormat>
        <autoVersionSubmodules>true</autoVersionSubmodules>
    </configuration>
</plugin>

发版执行命令

# 清理
mvn release:clean
#发版
mvn release:prepare -Darguments="-DskipTests"
#执行
mvn release:perform -DdryRun=true
#回滚
mvn release:rollback