Play 2.0: How to add SBT build number to page footer

playframework-2.0, sbt

Solution

I came up with an extension to the `bash` script that does the actual staging and starting of my application, thus providing the build information before even starting SBT / play. This extension grabs the revision of the working directory off the `Mercurial` repo and writes this with the current date into the file `conf/build-info.conf`. I refrained from using an automatically incremented build counter as the information provided by the repo should be sufficient.

#!/bin/bash
CHANGESET=`hg tip | grep changeset`
while IFS=":" read -ra PARTS; do
    REV=`echo "${PARTS[1]}" | tr -d ' '`@`hg branch`
    echo application.build=\"`date +"%Y-%m-%d"` "[$REV]"\" > conf/build-info.conf
done <<< "$CHANGESET"

resulting in a file containg a line similar to

application.build="2013-01-25 [98@bug-001]"

This script could easily be extended to `grep` the file `project/Build.scala` for the application version and include this in the build info created.

Feel free to copy/paste and adapt / improve. No attribution required but feedback here is always welcome :-)

Problem

I would like to add build information to the footer of my Play! application (Play! 2.0.4 with Scala), similar as done here on stackoverflow. I'm new to SBT and just happy that most of the time everything works like a charm. :-) Basically, I would like to extract the application version from `project/Build.scala`, add the current date, and finally add a build number (that is incremented automatically, but that may be the topic of another question to post). This information should be added to a file `conf/build-info.conf` that is included into the main `conf/application.conf`. I know how to extract the build info from the application configuration and add it to the pages. Thank you for your time!

Original source