Having Gradle Note Your Build Info

Managing Java server code you’ll employ a lot of monitoring tools, standard and often custom. But in addition to runtime info, I often want to know the build information of a process. What version is it? What is it dependent on? Who built it? When? Things like that. Ideally you want this reported in a consistent format so your monitoring tools can incorporate it.

Working somewhere that doesn’t yet have a standard for this, I wrote a minimal gradle plugin that gathers base information and creates a JSON file containing it. So, each build, this info can be branded into the code and then retrieved programmatically. For example, my RESTful servers just hang the file off a standard end point.

At this point the file looks something like:

    "project.name": "super-server",
    "project.version": "1.0.5",
    "builder": "jenkins",
    "build.date": "2015-12-30T20:13:06+0000",
    "java.vendor": "Oracle Corporation",
    "java.version": "1.8.0_60",
    "source.compatibility": "1.8",
    "target.compatibility": "1.8",
    "dependencies": [
    "custom": {
        "branch": "dev"

The plugin is dead simple to use, I just make gradle’s processResources task depend on it. You can take a look at the project on Github.


Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s