Using Maven to save the build time in a properties file

Create a folder called build in the root directory of the project, and a file with the following content:


Using the maven replacer plugin we can replace the token @buildtime@ within the file with the build timestamp value, and then let the Android application read that value and use it.


Run this task with mvn validate command. This will do nothing but replace the tokens from file with the timestamp value, and output the result to a new file in res/raw.

From here on the file can be accessed as a raw resource and read as a regular properties file.

Reading the properties file:

InputStream rawResource = resources.openRawResource(;
Properties properties = new Properties();
String buildTime = properties.getProperty("build.time");

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s