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 -->