Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying the build time-stamp in an application

Tags:

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?

like image 396
Artium Avatar asked Oct 23 '10 09:10

Artium


1 Answers

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

like image 125
Christoph Leiter Avatar answered Sep 27 '22 19:09

Christoph Leiter