Grails 3 - Adding build date and other custom info to war

It is very common requirement to add build date, build number, git commit etc. information to war. Lets see an example for how to add build date to war and display it on UI.

Gails gradle plugin adds buildProperties task to gradle build. This task is responsible for creating META-INF/ properties file which is included in the war. by default the file contains property values for grails env the war was built with, application name and version as defined in build file, and grails version. 

Properties from file can be accessed using <g:meta> tag


<g:meta name=""/>

Below is an example of how to add the new property build date to the build info file.

File: build.gradle

buildProperties {"", new Date().format('yyyy-MM-dd HH:mm:ss'))

File: application.yml

        name: ''
        version: ''
        grailsVersion: ''
          date: ''

After that the build date can be displayed on UI using the g:meta tag as shown below.

 <g:meta name=""/>

Note: This will only work when deployed as a war because of the fix made for the issue 10641