InfoGradleProcess

Introduction: Include Gradle process information in Build Scans or build output
More: Author   ReportBugs   
Tags:

Includes information about Gradle processes in the Build Scans or in the build output. The plugin is compatible with configuration cache.

[!NOTE] Since version 0.3.1 io.github.cdsap.gradleprocess can be applied in either settings.gradle(.kts) or a build script. Applying it in settings is recommended so process observation is configured once for the whole build (including multi-project builds). Existing build-script usage keeps working without changes.

Usage

Apply the plugin in the main settings.gradle(.kts) configuration file:

Kotlin

plugins {
  id("io.github.cdsap.gradleprocess") version "0.3.1"
}

Groovy

plugins {
  id "io.github.cdsap.gradleprocess" version "0.3.1"
}

Build script

The same plugin id can be applied in the root build.gradle(.kts):

Kotlin

plugins {
  id("io.github.cdsap.gradleprocess") version "0.3.1"
}

Groovy

plugins {
  id "io.github.cdsap.gradleprocess" version "0.3.1"
}

Applying the plugin from both settings and a build script is safe: processes are reported once per build.

Gradle properties

Add the property to the root project's gradle.properties file. It is disabled by default:

# gradle.properties
infoGradleProcess.gbos.enabled=true

With the property enabled, the plugin writes GBOS JSON and NDJSON reports under build/info-gradle-process/. If Develocity is applied, it also uses the GBOS projection instead of the legacy Gradle-Process-* custom values. Without the property, the existing console or legacy Develocity output remains enabled.

You can enable the same setting for one build without editing gradle.properties:

./gradlew build -PinfoGradleProcess.gbos.enabled=true

Output

Build Scans

If you are using Develocity, the information about the Gradle processes will be included as custom value in the Build Scan:

The field Usage represents the value obtained at the end of the build using jstat on the JVM process.

GBOS observations

GBOS output is disabled by default. Add the following to the root project's gradle.properties file, or pass it on the command line as -PinfoGradleProcess.gbos.enabled=true, to enable both local GBOS file sinks:

infoGradleProcess.gbos.enabled=true

When enabled, the plugin writes both build/info-gradle-process/gbos.json and build/info-gradle-process/gbos.ndjson. JSON is a GBOS report envelope and NDJSON contains one observation per line. Files are replaced after a successful build and are not appended or timestamped.

If Develocity is applied, the same property also enables the GBOS Build Scan projection and replaces the legacy Gradle-Process-* custom values.

infoGradleProcess.gbos.enabled Files Custom values (Develocity present)
false (default) none Gradle-Process-* only
true JSON and NDJSON GBOS only

Without Develocity, the property controls the file sinks and suppresses the console table when enabled; no Build Scan custom values are registered.

[!NOTE] Develocity 2024.2 provides new resource usage endpoints with detailed information about the different build and child processes during the execution: https://docs.gradle.com/develocity/api-manual/ref/2024.2.html#tag/Builds/operation/GetGradleResourceUsage

Build Output

If you are not using Develocity and GBOS is disabled, the information about the Gradle processes will be included at the end of the build:

> Task :core:ui:compileProdDebugKotlin
┌─────────────────────────────────────────────────────────────────────────────┐
│  Gradle processes                                                           │
├─────────┬──────────┬───────────┬────────────┬───────────────┬───────────────┤
│  PID    │  Max     │  Usage    │  Capacity  │  GC Time      │  Uptime       │
├─────────┼──────────┼───────────┼────────────┼───────────────┼───────────────┤
│  10865  │  1.0 Gb  │  0.66 Gb  │  1.0 Gb    │  0.0 minutes  │  0.0 minutes  │
├─────────┼──────────┼───────────┼────────────┼───────────────┼───────────────┤
│  9011   │  0.5 Gb  │  0.2 Gb   │  0.5 Gb    │  0.0 minutes  │  0.0 minutes  │
└─────────┴──────────┴───────────┴────────────┴───────────────┴───────────────┘
BUILD SUCCESSFUL in 35s

Requirements

  • Gradle 7.5+

Libraries

  • com.gradle:develocity-gradle-plugin
  • io.github.cdsap:build-observability-core
  • com.jakewharton.picnic:picnic
Apps
About Me
GitHub: Trinea
Facebook: Dev Tools
AI Daily Digest