Build data
publishData {
buildData()
}
adds a file build.data to the main resources. Your code can read it at runtime, for example to show its version or
to check for updates.
time=ISO 8601 timestamp of the build
unix=unix timestamp of the build
type=BUILD_TYPE environment variable, else PUBLIC or LOCAL
branch=branch, or none
commit=short commit hash, or none
artifactVersion=version
artifact=artifact name
runtime=Java runtime of the build
tag=tag the version was taken from, or none
channel=resolved channel
type is PUBLIC for CI builds and for local builds with PUBLIC_BUILD=true, LOCAL otherwise.
Options
publishData {
buildData {
fileName = "myplugin.data" // default build.data
includeTime = false // reproducible, cacheable output
put("discord", "https://discord.gg/…")
put("build", providers.environmentVariable("GITHUB_RUN_NUMBER"))
}
}
- Without
timeandunixthe file only depends on its inputs. The task is then cacheable and the artifact reproducible. - Your own entries are written after the built-in ones.
- The task is
generateBuildData. Its output lands inbuild/generated/publishdata.
In a multi-module build whose modules end up in one shaded jar, give the file
a name per module. Otherwise every module writes build.data and only one survives.