个人小结---本地Maven&Ant构建获取SVN版本号的方法

1.Maven获取SVN版本号

Pom.xml文件参考,只体现需要的部分,仅供个人备忘:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns="http://maven.apache.org/POM/4.0.0"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<properties>

<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>

</properties>

<scm>

        <connection>scm:svn:svn://localhost/app</connection>

        <developerConnection>scm:svn:svn://localhost/app</developerConnection>

</scm>

<build>

        <finalName>app-${buildNumber}</finalName>

        <plugins>

               <plugin>

                      <groupId>org.springframework.boot</groupId>

                      <artifactId>spring-boot-maven-plugin</artifactId>

                      <configuration>

                             <includeSystemScope>true</includeSystemScope>

                      </configuration>

                      <executions>

                             <execution>

                                    <goals>

                                           <goal>build-info</goal>

                                    </goals>

                                    <configuration>

                                           <additionalProperties>

                                                  <svn.revision>SVN-${env.SVN_REVISION}</svn.revision>

                                           <java.source>${maven.compiler.source}</java.source>

                                                <java.target>${maven.compiler.target}</java.target>

                                           </additionalProperties>

                                    </configuration>

                             </execution>

                      </executions>

               </plugin>

               <plugin>

                      <groupId>org.apache.maven.plugins</groupId>

                      <artifactId>maven-war-plugin</artifactId>

                      <configuration>

                             <webResources>

                                    <resource>

                                           <directory>lib</directory>

                                           <targetPath>WEB-INF/lib/</targetPath>

                                           <includes>

                                                  <include>**/*.jar</include>

                                           </includes>

                                    </resource>

                             </webResources>

                             <archive>

                                    <manifest>

                                    <addDefaultImplementationEntries>true</addDefaultImplementationEntries>

                                    </manifest>

                                    <manifestEntries>

                                           <url>${project.url}</url>

                                           <SVN-Revision>app-${buildNumber}</SVN-Revision>

                                    </manifestEntries>

                             </archive>

                      </configuration>

               </plugin>

               <!-- java编译插件 -->

               <plugin>

                      <groupId>org.apache.maven.plugins</groupId>

                      <artifactId>maven-compiler-plugin</artifactId>

                      <configuration>

                             <source>1.8</source>

                             <target>1.8</target>

                             <encoding>UTF-8</encoding>

                      </configuration>

               </plugin>

               <plugin>

                      <groupId>org.apache.maven.plugins</groupId>

                      <artifactId>maven-resources-plugin</artifactId>

               </plugin>

               <plugin>

                      <groupId>org.codehaus.mojo</groupId>

                      <artifactId>buildnumber-maven-plugin</artifactId>

                      <version>1.4</version>

                      <executions>

                             <execution>

                                    <phase>validate</phase>

                                    <goals>

                                           <goal>create</goal>

                                    </goals>

                             </execution>

                      </executions>

               </plugin>

        </plugins>

</build>

</project>

2.Ant获取SVN版本号

build.xml文件参考,只体现需要的部分,仅个人备忘:

<!-- SVN BEGIN -->

    <!-- 获取当前工程最新的SVN版本号 -->

    <echo>开始获取"Last Changed Rev",请确保工程代码为最新的;如果失败,请先按提示解决svn问题。</echo>

    <property name="svn-url" value="svn://localhost/app "></property>   

    <exec executable="svn" outputproperty="revisionNumber">

        <arg line="info ${svn-url} --show-item last-changed-revision"/>

    </exec>

    <echo>获取到的"Last Changed Rev": ${revisionNumber}</echo>

<!-- SVN END -->

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值