Is there a plugin (or another easy way) to generate a "random" number as part of a Maven build? I would like to assign this number to a property that I can then use in the pom.xml
file for some other purposes, e.g. for a filter value.
The number doesn't have to be completely random (hence the quotes), something using the current timestamp as a seed would be perfectly OK.
The default installation of maven offers a variable named maven.build.timestamp
, which gives you a timestamp. You can control the format with
<properties>
<maven.build.timestamp.format>yyyyMMdd-HHmm</maven.build.timestamp.format>
</properties>
which follows the SimpleDateFormat rules. So, you can simply just use ${maven.build.timestamp}
to get a formatted timestamp :)
http://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Available_Variables
You can use the timestamp maven plugin : http://code.google.com/p/maven-timestamp-plugin/
It generates the timestamp in maven property in the format you like.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With