Issue Details (XML | Word | Printable)

Key: MNG-2562
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: John Casey
Reporter: Brett Porter
Votes: 7
Watchers: 7
Operations

If you were logged in you would be able to see more operations.
Maven 2

expose current time as a property for POM interpolation

Created: 15/Sep/06 12:41 AM   Updated: Thursday 01:18 PM
Component/s: Inheritance and Interpolation
Affects Version/s: None
Fix Version/s: 2.1.0-M1

Time Tracking:
Not Specified

Issue Links:
Related
dependent

Complexity: Intermediate


 Description  « Hide
it is useful to have the current time, for example to write out a manifest entry for the build time or to filter into another file.

I'm not sure of the best way to make the format of the time configurable - perhaps another POM element/property.

See the related issue for a current example of how this can be done, but it would be nice to have a built-in.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Barend Garvelink added a comment - 14/Apr/08 04:16 AM
Brett Porter wrote:

I'm not sure of the best way to make the format of the time configurable - perhaps another POM element/property.

I think this issue should focus on merely adding the timestamp property, I think formatting is much better handled by MNG-3374. Reason: I may want to use multiple formats for the same timestamp, for example, UTC and ISO-8601 in the JAR manifest and Europe/Amsterdam with a custom pattern in a common footer JSP.

wrt reactor builds: is it desirable (or even possible) to add the timestamp for every sub-module in addition to the timestamp the build was started? The naming scheme could use Maven coordinates:

build.timestamp #time the build was started
build.timestamp.groupId:module1 #time module1 was started

Paul Benedict added a comment - 15/Apr/08 10:08 AM
Can property names include colons? I am referring to last example.

Shane Isbell added a comment - 15/May/08 12:52 PM
Bug fix here: https://svn.apache.org/repos/asf/maven/sandbox/branches/MNG-3536

This is part of a rewrite of the interpolation code.


Benjamin Bentmann added a comment - 17/Jun/08 02:55 AM

I'm not sure of the best way to make the format of the time configurable

I like the idea proposed by Sharmarke Aden in MNG-1832: ${mvn.timestamp.DATE_FORMAT}, i.e. simply appending the desired format to the propery base name. This allows users to easily choose the format for their respective use case.

The only thing that might be missing is the locale. Could perhaps be integrated like this: ${mvn.tstamp-lang,country,variant.DATE_FORMAT} which should be straightforward to parse.


Paul Benedict added a comment - 25/Jun/08 10:27 PM
If this is fixed, can someone comment on the resolution? What was chosen?

Wendy Smoak added a comment - 13/May/09 05:55 PM
A user asked about this on irc:

benson0: I'm lost in the maze of MNG-3718. Can someone just tell me the ${} to access a readable build date in 2.1.0? None of the syntaxes mentioned in the jiras seem to be right.
jason: ${build.timestamp}

I can't find it anywhere in the site, however grep does turn up a mention in maven-project-spec.tex as well as the code/tests.


Matthew McCullough added a comment - 01/Jul/09 06:07 PM
Per Wendy's last comment captured from benson0 and Jason, I'm after the same thing. I have a .properties file that is part of our filtered resources that I want to put the timestamp into. If I put ${build.timestamp} into the .properties file it isn't replaced. I see this interpolation in the source of the 2.2.0 branch of Maven, which we are using, in the file maven-project/src/main/java/org/apache/maven/project/interpolation/BuildTimestampValueSource.java

Even though I couldn't get it to work "raw", I did find a workaround. If I put
<properties>
<mytimestamp>${build.timestamp}</mytimestamp>
</properties>
into the pom.xml and then use ${mytimestamp} in the .properties file, it indeed does expand to 20090701-1656.

Benjamin Bentmann added a comment - 02/Jul/09 01:18 PM
Matthew, I believe there is probably a misunderstanding. We have to distinguish what gets interpolated (and by whom). The Maven core is only responsible for interpolating the POM, not the resources or any other project source files. The latter is the job for plugins, usually the Maven Resources Plugin. So you should fill the issue at the plugin which needs to be updated to support the timestamp as a new interpolation source. The plugin can fetch the value from the MavenSession.

BTW, I updated the site some time ago so that the feature in now documented, see Available Variable.