Class GreenerExtension
java.lang.Object
com.patbaumgartner.greener.gradle.GreenerExtension
DSL extension for the
greener block in Gradle build scripts.
All available options
greener {
// Optional - auto-detected from build/libs/ when omitted
springBootJar.set(file("build/libs/myapp.jar"))
jvmArgs.set(listOf("-Xmx512m"))
appArgs.set(listOf("--server.port=8080"))
// Joular Core
joularCoreBinaryPath.set(file("/usr/local/bin/joularcore")) // optional, auto-downloaded if absent
joularCoreVersion.set("0.0.1-beta-4")
joularCoreComponent.set("cpu") // "cpu" | "gpu" | "all"
// Joular Code Java (optional method-level monitoring)
joularCodeJavaAgentPath.set(file("joularcodejava-0.0.1.jar")) // optional
joularCodeJavaConfigPath.set(file("joularcodejava.properties")) // optional
// VM mode (virtualised environments - no direct RAPL access)
vmMode.set(true)
vmPowerFilePath.set(file("/tmp/vm-power.txt")) // host writes watts here every second
// Training workload — REQUIRED: set one of externalTrainingCommand / externalTrainingScriptFile
baseUrl.set("http://localhost:8080")
requestsPerSecond.set(5)
externalTrainingCommand.set("oha -n 500 -c 10 \${APP_URL}/actuator/health") // option A: inline command
externalTrainingScriptFile.set(file("examples/workloads/oha/run.sh")) // option B: script (takes precedence)
warmupDurationSeconds.set(30)
measureDurationSeconds.set(60)
startupTimeoutSeconds.set(120)
healthCheckPath.set("/actuator/health/readiness")
// Baseline & reporting
baselineFile.set(file("energy-baseline.json"))
threshold.set(10.0) // % regression allowed
failOnRegression.set(false)
reportOutputDir.set(file("build/greener-reports"))
latestReportFile.set(file("build/greener-reports/oha/latest-energy-report.json"))
// Auto-update & timestamped reports
autoUpdateBaseline.set(false) // auto-promote measurement to baseline
timestampReports.set(false) // append timestamp, create latest symlink
commitSha.set("...") // git SHA recorded in baseline (auto-detected from GITHUB_SHA)
branch.set("...") // branch recorded in baseline (auto-detected from GITHUB_REF_NAME)
// Report customisation
topN.set(20) // max methods in HTML report tables
// Skip execution
skip.set(false)
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract org.gradle.api.provider.ListProperty<String>Additional application arguments passed to the Spring Boot process.abstract org.gradle.api.provider.Property<Boolean>Whentrue, the measurement result is automatically promoted to the baseline after a successful run.abstract org.gradle.api.file.RegularFilePropertyPath to the JSON baseline file.abstract org.gradle.api.provider.Property<String>Base URL of the Spring Boot application.abstract org.gradle.api.provider.Property<String>Branch name to record in the baseline when auto-updating.abstract org.gradle.api.provider.Property<String>Git commit SHA to record in the baseline when auto-updating.abstract org.gradle.api.provider.Property<String>Optional external command used as the training workload (e.g.abstract org.gradle.api.file.RegularFilePropertyPath to an external shell script file used as the training workload.abstract org.gradle.api.provider.Property<Boolean>Whether to fail the build on energy regression beyondgetThreshold().abstract org.gradle.api.provider.Property<String>Health-check path used to detect when the application is ready.abstract org.gradle.api.provider.Property<Integer>Seconds to measure idle baseline power before workload (0 = disabled).abstract org.gradle.api.provider.Property<Integer>Number of independent measurement iterations (default 5).abstract org.gradle.api.file.RegularFilePropertyPath to the Joular Code Java agent jar.abstract org.gradle.api.file.RegularFilePropertyPath to the Joular Code Javajoularcodejava.propertiesfile.abstract org.gradle.api.file.RegularFilePropertyFull path to the Joular Core binary (optional; auto-downloaded when absent).abstract org.gradle.api.provider.Property<String>Hardware component to monitor:cpu,gpu, orall.abstract org.gradle.api.provider.Property<String>Joular Core release version to download whengetJoularCoreBinaryPath()is unset.abstract org.gradle.api.provider.ListProperty<String>Additional JVM arguments passed when starting the Spring Boot process.abstract org.gradle.api.file.RegularFilePropertyExplicit path to a report JSON file to promote duringupdateEnergyBaseline.abstract org.gradle.api.provider.Property<Integer>Duration in seconds of the actual measurement window after warmup.abstract org.gradle.api.provider.Property<com.patbaumgartner.greener.core.model.RegressionMetric>Regression metric: ENERGY_PER_REQUEST (default) or TOTAL_ENERGY.abstract org.gradle.api.file.DirectoryPropertyDirectory where the HTML report is written.abstract org.gradle.api.provider.Property<Integer>Requests per second (passed asRPSenvironment variable).abstract org.gradle.api.provider.Property<Boolean>getSkip()Whentrue, plugin execution is skipped entirely.abstract org.gradle.api.file.RegularFilePropertyPath to the executable Spring Boot fat-jar.abstract org.gradle.api.provider.Property<Integer>Seconds to wait for the application health endpoint before aborting.abstract org.gradle.api.provider.Property<Double>Maximum allowed percentage increase in total energy before the build is failed.abstract org.gradle.api.provider.Property<Boolean>Whentrue, the report output directory gets a timestamp suffix and alatestsymlink is created pointing to the most recent run.abstract org.gradle.api.provider.Property<Integer>getTopN()Maximum number of methods to display in HTML report tables.abstract org.gradle.api.provider.Property<Boolean>Enable Joular Core VM mode - for virtualised environments where RAPL counters are not directly accessible.abstract org.gradle.api.file.RegularFilePropertyPath to the file that provides VM power readings whengetVmMode()istrue.abstract org.gradle.api.provider.Property<Integer>Warmup duration in seconds.
-
Constructor Details
-
GreenerExtension
public GreenerExtension()
-
-
Method Details
-
getSpringBootJar
public abstract org.gradle.api.file.RegularFileProperty getSpringBootJar()Path to the executable Spring Boot fat-jar. When omitted the plugin auto-detects a single jar inbuild/libs/.- Returns:
- the Spring Boot jar property
-
getJvmArgs
Additional JVM arguments passed when starting the Spring Boot process.- Returns:
- the JVM arguments property
-
getAppArgs
Additional application arguments passed to the Spring Boot process.- Returns:
- the application arguments property
-
getJoularCoreBinaryPath
public abstract org.gradle.api.file.RegularFileProperty getJoularCoreBinaryPath()Full path to the Joular Core binary (optional; auto-downloaded when absent).- Returns:
- the Joular Core binary path property
-
getJoularCoreVersion
Joular Core release version to download whengetJoularCoreBinaryPath()is unset. See Joular Core releases for available versions.- Returns:
- the Joular Core version property
-
getJoularCoreComponent
Hardware component to monitor:cpu,gpu, orall.- Returns:
- the Joular Core component property
-
getJoularCodeJavaAgentPath
public abstract org.gradle.api.file.RegularFileProperty getJoularCodeJavaAgentPath()Path to the Joular Code Java agent jar. When set, the agent is attached to the Spring Boot JVM via-javaagent:for per-method energy monitoring.- Returns:
- the Joular Code Java agent path property
-
getJoularCodeJavaConfigPath
public abstract org.gradle.api.file.RegularFileProperty getJoularCodeJavaConfigPath()Path to the Joular Code Javajoularcodejava.propertiesfile. Used only whengetJoularCodeJavaAgentPath()is also set.- Returns:
- the Joular Code Java config path property
-
getBaseUrl
Base URL of the Spring Boot application.- Returns:
- the base URL property
-
getRequestsPerSecond
Requests per second (passed asRPSenvironment variable).- Returns:
- the requests per second property
-
getExternalTrainingCommand
Optional external command used as the training workload (e.g.k6 run script.js). TheAPP_URLenvironment variable is set togetBaseUrl().- Returns:
- the external training command property
-
getExternalTrainingScriptFile
public abstract org.gradle.api.file.RegularFileProperty getExternalTrainingScriptFile()Path to an external shell script file used as the training workload. Takes precedence overgetExternalTrainingCommand()when set.Available environment variables in the script:
APP_URL,APP_HOST,APP_PORT,WARMUP_SECONDS,MEASURE_SECONDS,TOTAL_SECONDS,RPS.See
examples/workloads/for wrk, wrk2, oha, and Gatling examples.- Returns:
- the external training script file property
-
getVmMode
Enable Joular Core VM mode - for virtualised environments where RAPL counters are not directly accessible. The host must write the VM's instantaneous power in Watts togetVmPowerFilePath()every second.- Returns:
- the VM mode property
-
getVmPowerFilePath
public abstract org.gradle.api.file.RegularFileProperty getVmPowerFilePath()Path to the file that provides VM power readings whengetVmMode()istrue. Must contain a single float (e.g.45.2).- Returns:
- the VM power file path property
-
getWarmupDurationSeconds
Warmup duration in seconds. The application runs under load during warmup so the JIT compiler warms up, but energy data from this phase is discarded.- Returns:
- the warmup duration property
-
getMeasureDurationSeconds
Duration in seconds of the actual measurement window after warmup.- Returns:
- the measure duration property
-
getStartupTimeoutSeconds
Seconds to wait for the application health endpoint before aborting.- Returns:
- the startup timeout property
-
getHealthCheckPath
Health-check path used to detect when the application is ready.- Returns:
- the health check path property
-
getBaselineFile
public abstract org.gradle.api.file.RegularFileProperty getBaselineFile()Path to the JSON baseline file.- Returns:
- the baseline file property
-
getThreshold
Maximum allowed percentage increase in total energy before the build is failed. For example10means a 10 % regression is tolerated.- Returns:
- the threshold property
-
getFailOnRegression
Whether to fail the build on energy regression beyondgetThreshold().- Returns:
- the fail on regression property
-
getReportOutputDir
public abstract org.gradle.api.file.DirectoryProperty getReportOutputDir()Directory where the HTML report is written.- Returns:
- the report output directory property
-
getLatestReportFile
public abstract org.gradle.api.file.RegularFileProperty getLatestReportFile()Explicit path to a report JSON file to promote duringupdateEnergyBaseline. When unset, the latest report is discovered automatically undergetReportOutputDir().- Returns:
- the latest report file property
-
getAutoUpdateBaseline
Whentrue, the measurement result is automatically promoted to the baseline after a successful run. Eliminates the need to callupdateEnergyBaselineseparately.- Returns:
- the auto-update baseline property
-
getCommitSha
Git commit SHA to record in the baseline when auto-updating.- Returns:
- the commit SHA property
-
getBranch
Branch name to record in the baseline when auto-updating.- Returns:
- the branch property
-
getTimestampReports
Whentrue, the report output directory gets a timestamp suffix and alatestsymlink is created pointing to the most recent run.- Returns:
- the timestamp reports property
-
getSkip
Whentrue, plugin execution is skipped entirely.- Returns:
- the skip property
-
getTopN
Maximum number of methods to display in HTML report tables.- Returns:
- the topN property
-
getIterations
Number of independent measurement iterations (default 5). Values >= 2 enable statistical comparison (Welch's t-test, Cohen's d).- Returns:
- the iterations property
-
getRegressionMetric
public abstract org.gradle.api.provider.Property<com.patbaumgartner.greener.core.model.RegressionMetric> getRegressionMetric()Regression metric: ENERGY_PER_REQUEST (default) or TOTAL_ENERGY.- Returns:
- the regression metric property
-
getIdleProbeSeconds
Seconds to measure idle baseline power before workload (0 = disabled).- Returns:
- the idle-probe-seconds property
-