Monday, January 18, 2016

Paperwork - a Gradle plugin to add build info to your project without breaking incremental builds


A common use case is that you want to include the git hash of the last commit and build time into your project, so that you can use their values in your crash reporting tool (for example).

The easiest way to do this is to generate them into your BuildConfig by adding these lines to your build.gradle:

But this will break incremental builds, resulting in increased build times all the time.

A solution could be to write information into an asset file instead of BuildConfig, and then read that file during runtime, which is exactly what Paperwork does:

https://github.com/zsoltk/paperwork

An added benefit is that you can now include any other information as well (output of a script maybe) that would result in a full recompile otherwise.