1. Installation

Check the installation instructions in the Gradle Plugin Portal.

2. Description

If a META-INF/build-info.properties file is available on the classpath, Micronaut framework's BuildInfoSource exposes the values in that file under the build key.

This Gradle plugin adds a task generateBuildInfo which is executed before the classes task. The task generates a build-info.properties file at build/classes/java/META-INFO/build-info.properties. The generated properties file includes version, name, group and optionally buildid. buildid is set to value of any of the following environment variables (TRAVIS_BUILD_ID, GITHUB_RUN_ID, CODEBUILD_BUILD_ID).

3. How to use it

3.1. Micronaut Example

% mn create-app example.micronaut.demo --features=management

Expose info endpoint:

---
endpoints:
  info:
    enabled: true
    sensitive: false

apply the plugin:

plugins {
  ...
  id "groovycalamari.build-info" version "0.0.2"
}

Then, run the app and hit the /info endpoint:

% ./gradlew run
% curl localhost:8080/info
{"name":"demo","version":"0.1","group":"com.example"}

4. Extension

You can override the defaults values with the extension buildInfo

property

default value

output

build/classes/java/main/META-INF/build-info.properties

buildIdKey

buildid

versionKey

version

nameKey

name

groupKey

group

Example:

buildInfo {
    output = "${project.buildDir}/classes/java/main/META-INF/build-info.properties"
    buildIdKey = 'buildid'
    versionKey = 'version'
    nameKey = 'name'
    groupKey = 'group'
}

5. Project Build