mvn release 配置说明
1、配置setting.xml
在setting.xml增加server
my-scm-server,对应的用户名、密码为git的用户名密码
<server>
<id>my-scm-server</id>
<username>******</username>
<password>******</password>
</server>
2、配置本项目中pom.xml
<!--[if !supportLists]-->1) <!--[endif]-->本地开发版本必须快照版本
<version>0.0.1-SNAPSHOT</version>
<!--[if !supportLists]-->2) <!--[endif]-->- 配置 project.scm.id 对应setting文件中my-scm-server
<project.scm.id>my-scm-server</project.scm.id>
<!--[if !supportLists]-->3) <!--[endif]-->scm配置
<!-- 配置代码git路径 -->
<scm>
<connection>scm:git:https://git.coding.net/******/common.settlement.sdk.git</connection>
<url>https://git.coding.net/******/common.settlement.sdk.git</url>
<developerConnection>scm:git:https://git.coding.net/******/common.settlement.sdk.git</developerConnection>
<tag>1</tag>
</scm>
<!--[if !supportLists]-->4) <!--[endif]-->增加maven-release-plugin插件
<plugins>
<!-- 发布源码到nexus-->
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</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>
<releaseProfiles>releases</releaseProfiles>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>nexus</serverId>
<nexusUrl>http://api.******.com/nexus/</nexusUrl>
<skipStaging>true</skipStaging>
</configuration>
</plugin>
</plugins>
<!--[if !supportLists]-->5) <!--[endif]-->增加部署配置
<distributionManagement>
<repository>
<id>releases</id>
<url>http://api.*****.com/nexus/content/repositories/releases</url>
</repository>
</distributionManagement>
3、命令执行
<!--[if !supportLists]-->1)<!--[endif]-->登陆 115.28.58.**
<!--[if !supportLists]-->2)<!--[endif]-->把代码clone到服务器
如果代码在主干上,直接clone主干
git clone https://username:password@git.coding.net/******/common.settlement.sdk.git
分支的需要clone分支
git clone -b test https://username:password@git.coding.net/******/common.settlement.sdk.git
3)在clone的目录下执行 release 命令
mvn release:clean release:prepare release:perform
maven-release-plugin会自动帮我们签出刚才打的tag,然后打包,分发到远程Maven仓库中,至此,整个版本的升级,打标签,发布等工作全部完成。我们可以在远程Maven仓库中看到正式发布的1.0版本。