Java web project deployed with Maven in MANIFEST.MF file "When did you compile?" I was asked to output, so I checked it, so make a note.
--Output the system time when Maven is executed to MANIFEST.MF in the jar file.
--Do not use AntRun Plugin. I don't want to build build.xml. --I don't want to write code.
First, how to use the property maven.build.timestamp prepared by Maven. See below. http://vbnmkyoto.blogspot.com/
pom.xml(Excerpt)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifestEntries>
<Build-Timestamp>${maven.build.timestamp}</Build-Timestamp>
</manifestEntries>
</archive>
</configuration>
</plugin>
To change the format, specify the format with the maven.build.timestamp.format property.
pom.xml(Excerpt)
<properties>
<maven.build.timestamp.format>yyyyMMhhmmss</maven.build.timestamp.format>
</properties>
If you do this, MANIFEST.MF will appear like this.
MANIFEST.MF
Build-Timestamp:20181129115959
Rakuchin ... But in Maven 3.2.2 or later, the output time is UTC. https://issues.apache.org/jira/browse/MNG-5452 It is inconvenient to work normally in Japan. I wish I could set the time zone, but I couldn't find anything like that.
I searched for something else like that and tried using the Build Helper Maven Plugin. See below. https://stackoverflow.com/questions/28281988/how-to-have-maven-show-local-timezone-in-maven-build-timestamp
pom.xml(Excerpt)
<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>yyyyMMddHHmmss</pattern>
<locale>ja_JP</locale>
<timeZone>Asia/Tokyo</timeZone>
</configuration>
</execution>
</executions>
</plugin>
Set the setting value of name in the description of the output part.
pom.xml(Excerpt)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifestEntries>
<Build-Timestamp>${build.time}</Build-Timestamp>
</manifestEntries>
</archive>
</configuration>
</plugin>
Now, the build execution time according to Japan time is output to MANIFEST.MF.
https://www.mojohaus.org/build-helper-maven-plugin/usage.html It seems to be convenient, so you may want to check it out a little more.
Recommended Posts