转载:增加svn版本
<!-- SVN版本号 -->
<plugin>
<groupId>com.google.code.maven-svn-revision-number-plugin</groupId>
<artifactId>maven-svn-revision-number-plugin</artifactId>
<version>1.7</version>
<configuration>
<verbose>true</verbose>
<entries>
<entry>
<prefix>svn</prefix>
</entry>
</entries>
</configuration>
<executions>
<execution>
<id>revision</id>
<phase>validate</phase>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.8.5</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifestEntries>
<SVN-Version>${svn.revision}</SVN-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
<!-- 构建时间 -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<timestampFormat>yyyy-MM-dd HH:mm:ss.S</timestampFormat>
<timestampPropertyName>buildTime</timestampPropertyName>
</configuration>
<executions>
<execution>
<id>create-timestamp</id>
<phase>validate</phase>
<goals>
<goal>create-timestamp</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifestEntries>
<!--suppress UnresolvedMavenProperty -->
<SVN-Version>${svn.revision}</SVN-Version>
<!--suppress UnresolvedMavenProperty -->
<Build-Time>${buildTime}</Build-Time>
</manifestEntries>
</archive>
</configuration>
</plugin>
配置完成后如下:

<!--在build标签中加入打包的名称-->
<!--suppress UnresolvedMavenProperty -->
<finalName>${artifactId}_${svn.revision}_${buildTime}</finalName>

<!-- 加入配置可以继续使用${}不需要使用@name@-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>utf-8</encoding>
<useDefaultDelimiters>true</useDefaultDelimiters>
</configuration>
</plugin>
浙公网安备 33010602011771号