在应用程序中显示构建时间戳 [英] Displaying the build time-stamp in an application

查看:29
本文介绍了在应用程序中显示构建时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在关于框中显示应用程序何时构建的时间戳.这将允许我跟踪应用程序的不同版本.如何在 Java 中检索此信息?

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?

推荐答案

有一个更简单的 maven 解决方案,它不需要 antrun 插件.Maven 有一个特殊的变量 maven.build.timestamp(自 Maven 2.1.0-M1 起).

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>

这将产生一行Build-Time: yyyyMMdd-HHmm".格式可以自定义:

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>

模式必须符合 SimpleDateFormat 的格式.

The pattern has to comply with the format of SimpleDateFormat.

参考:Maven 文档

这篇关于在应用程序中显示构建时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆