I would like to display the time-stamp of when the application was built in an about box. This will allow me tracking different versions of the application. How can I retrieve this information in Java?
There's a much simpler maven solution which doesn't require the antrun plugin. Maven has a special variable maven.build.timestamp (since Maven 2.1.0-M1).
<plugin> <artifactId>maven-war-plugin</artifactId> <!-- or maven-jar-plugin --> <version>2.2</version> <configuration> <archive> <manifestEntries> <Build-Time>${maven.build.timestamp}</Build-Time> </manifestEntries> </archive> </configuration> </plugin>
This will produce a line "Build-Time: yyyyMMdd-HHmm". The format can be customized with:
<properties> <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format> </properties>
The pattern has to comply with the format of SimpleDateFormat.
Reference: Maven Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With