Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant: Want to have a property that has a timestamp in it

Tags:

ant

I'm using Ant 1.8.2 on Ubuntu Linux (and also on Windows 7 running Cygwin). I have this property ...

    <property name="results" location="${selenium.results.dir}/Results-20110922_131005.html" />

I would like to replace the "20110922_131005" with something less hard coded that represents the current time stamp. How can I do this?

like image 661
Dave Avatar asked Sep 20 '11 18:09

Dave


People also ask

How do you set an Ant property?

The <property> task is used to set the Ant properties. The property value is immutable, once the value is set you cannot change it. To set a property to a specific value you use Name/value assignment. To set a property to a location you use Name/location assignment.

What does * stands for in * Test Java in Ant?

**\*.sql means "in the given directory and inside all of its subdirectories, all the files that end with .sql"

Where are Ant properties set?

The home directory for Ant library files - typically ANT_HOME/lib folder. Ant also makes the system properties (Example: file. separator) available to the build file. In addition to the above, the user can define additional properties using the property element.

What is property in Ant?

Properties are key-value pairs where Apache Ant tries to expand ${key} to value at run time. There are many tasks that can set properties; the most common one is the property task. In addition properties can be defined via command line arguments or similar mechanisms from outside of Ant.


2 Answers

<tstamp>
     <format property="time.stamp" pattern="yyyy-MM-dd_HH:mm:ss"/>
</tstamp>

This will create a property called ${time.stamp}.

<property name="results" 
    location="${selenium.results.dir}/Results-${time.stamp}.html" />
like image 76
David W. Avatar answered Sep 21 '22 18:09

David W.


you can use tstamp in ant. Also look at SO Question : output timestamp in ant

like image 43
kdabir Avatar answered Sep 21 '22 18:09

kdabir