maven构建时获取svn版本号

原文:http://mojo.codehaus.org/buildnumber-maven-plugin/usage.html


需要插件:buildnumber-maven-plugin

 

<build>
<plugins>
  <plugin>
	<groupId>org.codehaus.mojo</groupId>
	<artifactId>buildnumber-maven-plugin</artifactId>
	<version>1.3</version>
	<executions>
	  <execution>
		<phase>validate</phase>
		<goals>
		  <goal>create</goal>
		</goals>
	  </execution>
	</executions>
	<configuration>
          <!--如果这里都配置为true,需要配置scm url-->
	  <doCheck>true</doCheck>
	  <doUpdate>true</doUpdate>
	</configuration>
  </plugin>
</plugins>
</build>

 

<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/xsd/maven-4.0.0.xsd">
	
	<scm>
        <connection>scm:svn:svn://169.254.11.11:3690/xxx</connection>
        <developerConnection>scm:svn:svn://169.254.11.11:3690/xxx</developerConnection>
        <url>scm:svn:svn://169.254.11.11:3690/xxx</url>
    </scm>
</project>

 

再通过${buildNumber}来获取svn版本号即可

<build>

    <finalName>${project.artifactId}-${project.version}-r${buildNumber}</finalName>

 </build>

你可能感兴趣的:(maven)