Skip to content

Instantly share code, notes, and snippets.

@dumbdonkey
Last active January 16, 2020 03:51
Show Gist options
  • Select an option

  • Save dumbdonkey/2802b538779f8672b7e7b5aa9eb5a451 to your computer and use it in GitHub Desktop.

Select an option

Save dumbdonkey/2802b538779f8672b7e7b5aa9eb5a451 to your computer and use it in GitHub Desktop.
maven生成版本号
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>timestamp-property</id>
<goals>
<goal>timestamp-property</goal>
</goals>
<configuration>
<name>build.time</name>
<pattern>yyyy-MM-dd HH:mm:ss</pattern>
<timeZone>GMT+8</timeZone>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>src/main/resources/META-INF/Version.java.template</file>
<outputFile>XXX/Version.java</outputFile>
<replacements>
<replacement>
<token>#buildTime#</token>
<value>${build.time}</value>
</replacement>
<replacement>
<token>#pomVersion#</token>
<value>${project.version}</value>
</replacement>
</replacements>
</configuration>
</plugin>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment