使用maven管理项目时,完成开发后需要把项目发布到maven私服上去。
手动SNAPSHOT版本开发时执行mvn clean deploy就可以部署到私服上。
在开发是还会需要SNAPSHOT版本和RELEASE版本可以用mvn versions:set -DnewVersion=0.1.1-SNAPSHOT进行更改版本号
当然maven还有更好的管理插件进行RELEASE管理maven-release-plugin
在pom.xml添加插件
| 12
 3
 4
 5
 6
 7
 8
 9
 
 | <build><plugins>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-release-plugin</artifactId>
 <version>2.5.3</version>
 </plugin>
 </plugins>
 </build>
 
 | 
在pom.xml添加scm信息(SCM:Software Configuration Management)
| 12
 3
 4
 5
 6
 7
 8
 
 | <scm>
 <url>http://192.168.8.65/xx/cli</url>
 
 <connection>scm:git:http://192.168.8.65/xx/cli.git</connection>
 <developerConnection>scm:git:http://192.168.8.65/xx/cli.git</developerConnection>
 <tag>HEAD</tag>
 </scm>
 
 | 
配置好后可以使用mvn的scm命令管理
添加scm插件
| 12
 3
 4
 5
 6
 
 | <plugin><groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-scm-plugin</artifactId>
 <version>1.9.5</version>
 </plugin>
 
 
 | 
| 12
 3
 4
 5
 
 |  mvn -Dmessage="<commit_log_here>" scm:checkin
 
 
 mvn scm:update
 
 | 
SCM支持两种连接类型:connection 及 developerConnection
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 
 | <build><plugins>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-scm-plugin</artifactId>
 <version>1.8.1</version>
 <configuration>
 
 <connectionType>connection</connectionType>
 </configuration>
 </plugin>
 </plugins>
 </build>
 
 | 
项目是SNAPSHOT版本开发好之后就可以发布RELEASE版了,直接使用
| 12
 3
 4
 5
 6
 7
 8
 
 | mvn release:prepare
 
 
 mvn release:perform
 
 
 mvn release:rollback
 
 | 
使用mvn release命令时 如需要添加跳过测试之类的参数 需要使用-Darguments进行指定
| 1
 | mvn release:perform -Darguments="-Dmaven.test.skip=true -Dmaven.javadoc.skip=true" 
 |