Generate random number during Maven build

Is there a plugin (or other simple way) to create a "random" number as part of a Maven assembly? I would like to assign this number to a property which can then be used in the pom.xml file for some other purposes, for example. for the filter value.

The number does not have to be completely random (hence, quotation marks), something using the current timestamp as a seed will be perfectly fine.

+4
source share
2 answers

The default installation of maven offers a variable called maven.build.timestamp that gives you a timestamp. You can control the format using

  <properties> <maven.build.timestamp.format>yyyyMMdd-HHmm</maven.build.timestamp.format> </properties> 

which follows the rules of SimpleDateFormat . That way you can just use ${maven.build.timestamp} to get a formatted timestamp :)

http://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Available_Variables

+6
source

You can use the timestamp maven plugin: http://code.google.com/p/maven-timestamp-plugin/

It generates a timestamp in the maven property in whatever format you like.

+2
source

All Articles