Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding build time into JAR Manifest using Ant

Tags:

If I want to embed the current time in JAR manifest using ant is there an ant property I can use for "now" and which manifest attribute is the best to put this information?

I currently have the following

  <manifest>
    <attribute name="Signature-Title" value="${project.name}"/>
    <attribute name="Signature-Version" value="${release.version}"/>
    <attribute name="Signature-Vendor" value="XXX"/>
    <attribute name="Built-By" value="${user.name}"/>
  </manifest>
like image 800
Mike Q Avatar asked Nov 10 '10 10:11

Mike Q


1 Answers

You can use the tstamp task for this.

 <tstamp>
    <format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss" />
  </tstamp>

  <manifest>
    <attribute name="Signature-Title" value="${project.name}"/>
    <attribute name="Signature-Version" value="${release.version}"/>
    <attribute name="Signature-Vendor" value="XXX"/>
    <attribute name="Built-By" value="${user.name}"/>
    <attribute name="Built-Date" value="${TODAY}"/>
  </manifest>

This task set three properties (DSTAMP, TSTAMP, and TODAY) with the current timestamp, each in a different default format (check the link). With the nested format node, you can define a custom format for any of them.

like image 153
Tomas Narros Avatar answered Sep 22 '22 12:09

Tomas Narros