这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
分享:技术:maven:maven_scm_release_plugin [2015/07/07 15:19] gxx |
分享:技术:maven:maven_scm_release_plugin [2015/07/07 15:51] (当前版本) gxx |
||
---|---|---|---|
行 14: | 行 14: | ||
接着上面继续讲,每次正式的发布你都可以手工一步步的做这些事情,无非就是一些svn操作,一些pom编辑,还有一些mvn操作。但是重复手工做这些事情,一来繁琐,而来容易出错。因此maven-scm-plugin插件和maven-release-plugin插件就是用来自动化这一系列动作。 | 接着上面继续讲,每次正式的发布你都可以手工一步步的做这些事情,无非就是一些svn操作,一些pom编辑,还有一些mvn操作。但是重复手工做这些事情,一来繁琐,而来容易出错。因此maven-scm-plugin插件和maven-release-plugin插件就是用来自动化这一系列动作。 | ||
===== 操作 ===== | ===== 操作 ===== | ||
+ | ==== pom.xml源码 ==== | ||
+ | 注意其中的: | ||
+ | * scm软件配置管理 | ||
+ | * nexus私服仓库 | ||
+ | * scm软件配置管理插件 | ||
+ | * 版本发布插件 | ||
+ | * 版本发布管理 | ||
+ | <code xml pom.xml> | ||
+ | <?xml version="1.0" encoding="UTF-8"?> | ||
+ | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
+ | <modelVersion>4.0.0</modelVersion> | ||
+ | <groupId>com.gxx</groupId> | ||
+ | <artifactId>record</artifactId> | ||
+ | <packaging>war</packaging> | ||
+ | <version>0.0.1-SNAPSHOT</version> | ||
+ | <name>record Maven Webapp</name> | ||
+ | <url>http://maven.apache.org</url> | ||
+ | |||
+ | <!-- 项目属性 --> | ||
+ | <properties> | ||
+ | <!-- jar 版本设置 --> | ||
+ | <spring.version>4.0.5.RELEASE</spring.version> | ||
+ | <aspectjrt.version>1.6.9</aspectjrt.version> | ||
+ | <aspectjweaver.version>1.6.1</aspectjweaver.version> | ||
+ | <freemarker.version>2.3.20</freemarker.version> | ||
+ | <mybatis.version>3.2.7</mybatis.version> | ||
+ | <mybatis-spring.version>1.2.2</mybatis-spring.version> | ||
+ | <mybatis-generator-core.version>1.3.2</mybatis-generator-core.version> | ||
+ | <servlet-api.version>2.4</servlet-api.version> | ||
+ | <jsp-api.version>2.0</jsp-api.version> | ||
+ | <jstl.version>1.2</jstl.version> | ||
+ | <standard.version>1.1.2</standard.version> | ||
+ | <jackson-databind.version>2.4.0</jackson-databind.version> | ||
+ | <jackson-annotations.version>2.4.0</jackson-annotations.version> | ||
+ | <jackson-module-jaxb-annotations.version>2.4.0</jackson-module-jaxb-annotations.version> | ||
+ | <jackson-core.version>2.4.0</jackson-core.version> | ||
+ | <junit.version>4.11</junit.version> | ||
+ | <log4j.version>1.2.16</log4j.version> | ||
+ | <mysql-connector-java.version>5.1.9</mysql-connector-java.version> | ||
+ | <commons-dbcp.version>1.4</commons-dbcp.version> | ||
+ | </properties> | ||
+ | |||
+ | <!-- scm软件配置管理 --> | ||
+ | <scm> | ||
+ | <connection>scm:svn:svn://121.43.104.34/gxx/trunk/record</connection> | ||
+ | <developerConnection>scm:svn:svn://121.43.104.34/gxx/trunk/record</developerConnection> | ||
+ | </scm> | ||
+ | |||
+ | <dependencies> | ||
+ | <!-- Spring --> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-core</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-beans</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-context</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-context-support</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-aop</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-jdbc</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-web</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.springframework</groupId> | ||
+ | <artifactId>spring-webmvc</artifactId> | ||
+ | <version>${spring.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- aspectj --> | ||
+ | <dependency> | ||
+ | <groupId>org.aspectj</groupId> | ||
+ | <artifactId>aspectjrt</artifactId> | ||
+ | <version>${aspectjrt.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.aspectj</groupId> | ||
+ | <artifactId>aspectjweaver</artifactId> | ||
+ | <version>${aspectjweaver.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- freemarker --> | ||
+ | <dependency> | ||
+ | <groupId>org.freemarker</groupId> | ||
+ | <artifactId>freemarker</artifactId> | ||
+ | <version>${freemarker.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- mybatis --> | ||
+ | <dependency> | ||
+ | <groupId>org.mybatis</groupId> | ||
+ | <artifactId>mybatis</artifactId> | ||
+ | <version>${mybatis.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.mybatis</groupId> | ||
+ | <artifactId>mybatis-spring</artifactId> | ||
+ | <version>${mybatis-spring.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>org.mybatis.generator</groupId> | ||
+ | <artifactId>mybatis-generator-core</artifactId> | ||
+ | <version>${mybatis-generator-core.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- j2ee基础 --> | ||
+ | <dependency> | ||
+ | <groupId>javax.servlet</groupId> | ||
+ | <artifactId>servlet-api</artifactId> | ||
+ | <version>${servlet-api.version}</version> | ||
+ | <scope>provided</scope> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>javax.servlet.jsp</groupId> | ||
+ | <artifactId>jsp-api</artifactId> | ||
+ | <version>${jsp-api.version}</version> | ||
+ | <scope>provided</scope> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>javax.servlet</groupId> | ||
+ | <artifactId>jstl</artifactId> | ||
+ | <version>${jstl.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>taglibs</groupId> | ||
+ | <artifactId>standard</artifactId> | ||
+ | <version>${standard.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- jackson --> | ||
+ | <dependency> | ||
+ | <groupId>com.fasterxml.jackson.core</groupId> | ||
+ | <artifactId>jackson-databind</artifactId> | ||
+ | <version>${jackson-databind.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>com.fasterxml.jackson.core</groupId> | ||
+ | <artifactId>jackson-annotations</artifactId> | ||
+ | <version>${jackson-annotations.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>com.fasterxml.jackson.module</groupId> | ||
+ | <artifactId>jackson-module-jaxb-annotations</artifactId> | ||
+ | <version>${jackson-module-jaxb-annotations.version}</version> | ||
+ | </dependency> | ||
+ | <dependency> | ||
+ | <groupId>com.fasterxml.jackson.core</groupId> | ||
+ | <artifactId>jackson-core</artifactId> | ||
+ | <version>${jackson-core.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- log4j --> | ||
+ | <dependency> | ||
+ | <groupId>log4j</groupId> | ||
+ | <artifactId>log4j</artifactId> | ||
+ | <version>${log4j.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- junit --> | ||
+ | <dependency> | ||
+ | <groupId>junit</groupId> | ||
+ | <artifactId>junit</artifactId> | ||
+ | <scope>test</scope> | ||
+ | <version>${junit.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- mysql --> | ||
+ | <dependency> | ||
+ | <groupId>mysql</groupId> | ||
+ | <artifactId>mysql-connector-java</artifactId> | ||
+ | <version>${mysql-connector-java.version}</version> | ||
+ | </dependency> | ||
+ | |||
+ | <!-- dbcp --> | ||
+ | <dependency> | ||
+ | <groupId>commons-dbcp</groupId> | ||
+ | <artifactId>commons-dbcp</artifactId> | ||
+ | <version>${commons-dbcp.version}</version> | ||
+ | </dependency> | ||
+ | </dependencies> | ||
+ | |||
+ | <!-- 设定除中央仓repo1.maven.org/maven2/)外的其他仓库,按设定顺序进行查 --> | ||
+ | <repositories> | ||
+ | <!-- nexus私服仓库 --> | ||
+ | <repository> | ||
+ | <id>nexus</id> | ||
+ | <name>Team Nexus Repository</name> | ||
+ | <url>http://121.43.104.34:8081/nexus/content/groups/public</url> | ||
+ | </repository> | ||
+ | <repository> | ||
+ | <id>offical</id> | ||
+ | <name>Maven Official Repository</name> | ||
+ | <url>http://repo1.maven.org/maven2</url> | ||
+ | <snapshots> | ||
+ | <enabled>false</enabled> | ||
+ | </snapshots> | ||
+ | </repository> | ||
+ | <repository> | ||
+ | <id>spring-milestone</id> | ||
+ | <name>Spring Maven MILESTONE Repository</name> | ||
+ | <url>http://maven.springframework.org/milestone</url> | ||
+ | </repository> | ||
+ | <repository> | ||
+ | <id>jboss</id> | ||
+ | <name>Jboss Repository</name> | ||
+ | <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url> | ||
+ | <snapshots> | ||
+ | <enabled>false</enabled> | ||
+ | </snapshots> | ||
+ | </repository> | ||
+ | <repository> | ||
+ | <id>java.net</id> | ||
+ | <name>Java.net Repository</name> | ||
+ | <url>http://download.java.net/maven/2/</url> | ||
+ | <snapshots> | ||
+ | <enabled>false</enabled> | ||
+ | </snapshots> | ||
+ | </repository> | ||
+ | <repository> | ||
+ | <id>spring-release</id> | ||
+ | <name>Spring Maven Release Repository</name> | ||
+ | <url>http://repo.springsource.org/libs-release</url> | ||
+ | <snapshots> | ||
+ | <enabled>false</enabled> | ||
+ | </snapshots> | ||
+ | </repository> | ||
+ | </repositories> | ||
+ | |||
+ | <build> | ||
+ | <finalName>record</finalName> | ||
+ | <plugins> | ||
+ | <!-- jdk编译插件 --> | ||
+ | <plugin> | ||
+ | <groupId>org.apache.maven.plugins</groupId> | ||
+ | <artifactId>maven-compiler-plugin</artifactId> | ||
+ | <version>2.0.2</version> | ||
+ | <configuration> | ||
+ | <source>1.6</source> | ||
+ | <target>1.6</target> | ||
+ | <encoding>utf8</encoding> | ||
+ | </configuration> | ||
+ | </plugin> | ||
+ | <!-- scm软件配置管理插件 --> | ||
+ | <plugin> | ||
+ | <groupId>org.apache.maven.plugins</groupId> | ||
+ | <artifactId>maven-scm-plugin</artifactId> | ||
+ | <version>1.3</version> | ||
+ | </plugin> | ||
+ | <!-- 版本发布插件 --> | ||
+ | <plugin> | ||
+ | <groupId>org.apache.maven.plugins</groupId> | ||
+ | <artifactId>maven-release-plugin</artifactId> | ||
+ | <version>2.4</version> | ||
+ | <configuration> | ||
+ | <tagBase>svn://121.43.104.34/gxx/tags/record</tagBase> | ||
+ | <branchBase>svn://121.43.104.34/gxx/branches/record</branchBase> | ||
+ | </configuration> | ||
+ | </plugin> | ||
+ | <!-- 原型插件 --> | ||
+ | <plugin> | ||
+ | <groupId>org.apache.maven.plugins</groupId> | ||
+ | <artifactId>maven-archetype-plugin</artifactId> | ||
+ | <version>2.2</version> | ||
+ | </plugin> | ||
+ | </plugins> | ||
+ | </build> | ||
+ | |||
+ | <!-- 版本发布管理 --> | ||
+ | <distributionManagement> | ||
+ | <!-- release稳定版本 --> | ||
+ | <repository> | ||
+ | <id>nexus-releases</id> | ||
+ | <name>Nexus Release Repository</name> | ||
+ | <url>http://121.43.104.34:8081/nexus/content/repositories/releases/</url> | ||
+ | </repository> | ||
+ | <!-- snapshots快照版本 --> | ||
+ | <snapshotRepository> | ||
+ | <id>nexus-snapshots</id> | ||
+ | <name>Nexus Snapshot Repository</name> | ||
+ | <url>http://121.43.104.34:8081/nexus/content/repositories/snapshots/</url> | ||
+ | </snapshotRepository> | ||
+ | </distributionManagement> | ||
+ | </project> | ||
+ | </code> | ||
+ | ==== 操作步骤 ==== | ||
<file> | <file> | ||
D:\05.HeadWorkspace\record>mvn release:prepare #进入项目目录,dir会看到pom.xml,当前版本是0.0.1-SNAPSHOT,执行脚本 | D:\05.HeadWorkspace\record>mvn release:prepare #进入项目目录,dir会看到pom.xml,当前版本是0.0.1-SNAPSHOT,执行脚本 | ||
行 32: | 行 339: | ||
[INFO] Checking dependencies and plugins for snapshots ... | [INFO] Checking dependencies and plugins for snapshots ... | ||
What is the release version for "record Maven Webapp"? (com.gxx:record) 0.0.1: : | What is the release version for "record Maven Webapp"? (com.gxx:record) 0.0.1: : | ||
+ | ############################################################################### | ||
->输入回车,以0.0.1为发布版本,也可以输入新的版本 | ->输入回车,以0.0.1为发布版本,也可以输入新的版本 | ||
+ | ############################################################################### | ||
What is SCM release tag or label for "record Maven Webapp"? (com.gxx:record) rec | What is SCM release tag or label for "record Maven Webapp"? (com.gxx:record) rec | ||
ord-0.0.1: : | ord-0.0.1: : | ||
+ | ############################################################################### | ||
->输入回车,以record-0.0.1为tag标签名称,也可以输入新的标签 | ->输入回车,以record-0.0.1为tag标签名称,也可以输入新的标签 | ||
+ | ############################################################################### | ||
What is the new development version for "record Maven Webapp"? (com.gxx:record) | What is the new development version for "record Maven Webapp"? (com.gxx:record) | ||
0.0.2-SNAPSHOT: : | 0.0.2-SNAPSHOT: : | ||
+ | ############################################################################### | ||
->输入回车,以0.0.2-SNAPSHOT为新的开发版本,也可以输入新的版本 | ->输入回车,以0.0.2-SNAPSHOT为新的开发版本,也可以输入新的版本 | ||
+ | ############################################################################### | ||
... | ... | ||
[INFO] Release preparation complete. | [INFO] Release preparation complete. | ||
行 49: | 行 362: | ||
[INFO] ------------------------------------------------------------------------ | [INFO] ------------------------------------------------------------------------ | ||
############################################################################### | ############################################################################### | ||
- | 这个时候在svn://121.43.104.34/gxx/tags/record下可以看到名字为record-0.0.1的tag | + | #这个时候在svn://121.43.104.34/gxx/tags/record下可以看到名字为record-0.0.1的tag |
- | pom.xml从0.0.1-SNAPSHOT变成0.0.2-SNAPSHOT,并提交svn | + | #pom.xml从0.0.1-SNAPSHOT变成0.0.2-SNAPSHOT,并提交svn |
- | record文件夹下会出现俩文件:pom.xml.releaseBackup和release.properties | + | #record文件夹下会出现俩文件:pom.xml.releaseBackup和release.properties |
D:\05.HeadWorkspace\record>mvn release:perform #再执行脚本 | D:\05.HeadWorkspace\record>mvn release:perform #再执行脚本 | ||
- | maven-release-plugin会自动帮我们检出刚才打的tag,然后打包,分发到nexus私有仓库中 | + | #maven-release-plugin会自动帮我们检出刚才打的tag,然后打包,分发到nexus私有仓库中 |
+ | </file> | ||
+ | ==== 结束检查 ==== | ||
+ | 查看pom.xml | ||
+ | {{ :分享:技术:maven:maven插件截图3.png?300 |}} | ||
+ | 查看svn | ||
+ | {{ :分享:技术:maven:maven插件截图1.png?200 |}} | ||
+ | 查看nexus | ||
+ | {{ :分享:技术:maven:maven插件截图2.png?300 |}} | ||
+ | ==== 错误记录 ==== | ||
+ | 在这个过程中我报过一些错误,这里都记录了下来,如果有相同的错误信息出现,可以参考后面跟的解决方案 | ||
+ | <file> | ||
+ | 报错: | ||
+ | [ERROR] Command output: | ||
+ | [ERROR] 'svn' 不是内部或外部命令,也不是可运行的程序 | ||
+ | [ERROR] 或批处理文件。 | ||
+ | |||
+ | 解决方法: | ||
+ | windows安装svn的时候默认是不安装 svn command line这个东西的,重新打开svn的安装exe,选择modify,将“command line client tools”允许安装,然后next继续安装(注意版本一致性)。 | ||
+ | http://blog.csdn.net/mitea90/article/details/19075673 | ||
+ | </file> | ||
+ | <file> | ||
+ | 报错: | ||
+ | [ERROR] Command output: | ||
+ | [ERROR] svn: E155007: 'D:\05.HeadWorkspace\record\pom.xml' is not a working copy | ||
+ | |||
+ | 解决方法: | ||
+ | 项目必须是从svn仓库co出来的 | ||
+ | </file> | ||
+ | <file> | ||
+ | 报错: | ||
+ | [ERROR] svn: E155036: Please see the 'svn upgrade' command | ||
+ | [ERROR] svn: E155036: The working copy at 'D:\05.HeadWorkspace\record' | ||
+ | [ERROR] is too old (format 29) to work with client version '1.8.10 (r1615264)' ( | ||
+ | expects format 31). You need to upgrade the working copy first. | ||
+ | |||
+ | 解决方法: | ||
+ | 对本地文件夹进行一次upgrade操作,在项目文件夹上右键,svn upgrade | ||
+ | </file> | ||
+ | <file> | ||
+ | 报错: | ||
+ | [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4 | ||
+ | :prepare (default-cli) on project record: Cannot prepare the release because you | ||
+ | have local modifications : | ||
+ | [ERROR] [pom.xml:modified] | ||
+ | [ERROR] [src\main\java\com\gxx\record\web\user\UserController.java:modified] | ||
+ | [ERROR] [src\main\webapp\WEB-INF\ftl\user\preRegist.ftl:deleted] | ||
+ | [ERROR] [src\main\webapp\WEB-INF\ftl\user\preRegistFtl.ftl:added] | ||
+ | |||
+ | 解决方法: | ||
+ | 由于要发布release版本,前提一定要代码先提交完,所以要先提交代码 | ||
+ | </file> | ||
+ | <file> | ||
+ | 报错: | ||
+ | [ERROR] The svn tag command failed. | ||
+ | [ERROR] Command output: | ||
+ | [ERROR] svn: E160013: File not found: transaction '6-6', path '/tags/record/reco | ||
+ | rd-0.0.1' | ||
+ | |||
+ | 解决方法: | ||
+ | trunk,tags,branches需要import导入初始化资源,客户端才能读取和提交内容到该目录下 | ||
</file> | </file> |