Maven构建可执行jar,输出构建时间到MANIFEST.MF
2017-08-02 本文已影响0人
花绽放水流年
使用插件的方式
<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>
</execution>
</executions>
<configuration>
<name>current.time</name>
<pattern>yyyyMMddHHmmss</pattern>
<timeZone>GMT+8</timeZone>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<manifestEntries>
<Main-Version>${current.time}</Main-Version>
</manifestEntries>
<manifest>
<mainClass>platform.MainApplication</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
<excludes>
<exclude>test</exclude>
</excludes>
<classesDirectory>target/classes/</classesDirectory>
</configuration>
</plugin>