Labels

continuous integration (9) jenkins (9) hudson (7) mac os x (5) maven (5) git (4) android (3) charles (3) launchd (3) scm (3) bitbucket (2) dvcs (2) jnlp (2) mercurial (2) python (2) ant (1) apple (1) basex (1) chrome (1) cloud server (1) cobertura (1) css (1) cvs (1) firefox (1) general (1) hardy (1) http (1) iptables (1) java (1) javascript (1) linux (1) lucid (1) stresstest (1) subversion (1) svn (1) ubuntu (1) xen (1) xml (1) xpath (1) yui2 (1)

2010/09/05

A simple way to get a git hash as version info into Android applications using Maven

I recently decided to do some Android programming. Enters Mittagstisch KA. I really like to know which sources applications are built from. Using Maven and it's Antrun-Plugin this is rather simple:

This will create a new string resource file, which is automatically picked up by Android's resource compiler and might be read in your application by an Activity like this:


final String gitHash = getResources().getString(R.string.info_githash);

Do not forget to add res/values/githash.xml to your .gitignore file otherwise you will be committing infinitely :-).

0 comments:

Post a Comment