dumbdonkey
7/26/2018 - 5:50 AM

maven生成版本号

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>