Class GreenerExtension

java.lang.Object
com.patbaumgartner.greener.gradle.GreenerExtension

public abstract class GreenerExtension extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.gradle.api.provider.ListProperty<String>
    Additional application arguments passed to the Spring Boot process.
    abstract org.gradle.api.provider.Property<Boolean>
    When true, the measurement result is automatically promoted to the baseline after a successful run.
    abstract org.gradle.api.file.RegularFileProperty
    Path 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.RegularFileProperty
    Path 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 beyond getThreshold().
    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.RegularFileProperty
    Path to the Joular Code Java agent jar.
    abstract org.gradle.api.file.RegularFileProperty
    Path to the Joular Code Java joularcodejava.properties file.
    abstract org.gradle.api.file.RegularFileProperty
    Full path to the Joular Core binary (optional; auto-downloaded when absent).
    abstract org.gradle.api.provider.Property<String>
    Hardware component to monitor: cpu, gpu, or all.
    abstract org.gradle.api.provider.Property<String>
    Joular Core release version to download when getJoularCoreBinaryPath() is unset.
    abstract org.gradle.api.provider.ListProperty<String>
    Additional JVM arguments passed when starting the Spring Boot process.
    abstract org.gradle.api.file.RegularFileProperty
    Explicit path to a report JSON file to promote during updateEnergyBaseline.
    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.DirectoryProperty
    Directory where the HTML report is written.
    abstract org.gradle.api.provider.Property<Integer>
    Requests per second (passed as RPS environment variable).
    abstract org.gradle.api.provider.Property<Boolean>
    When true, plugin execution is skipped entirely.
    abstract org.gradle.api.file.RegularFileProperty
    Path 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>
    When true, the report output directory gets a timestamp suffix and a latest symlink is created pointing to the most recent run.
    abstract org.gradle.api.provider.Property<Integer>
    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.RegularFileProperty
    Path to the file that provides VM power readings when getVmMode() is true.
    abstract org.gradle.api.provider.Property<Integer>
    Warmup duration in seconds.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 in build/libs/.
      Returns:
      the Spring Boot jar property
    • getJvmArgs

      public abstract org.gradle.api.provider.ListProperty<String> getJvmArgs()
      Additional JVM arguments passed when starting the Spring Boot process.
      Returns:
      the JVM arguments property
    • getAppArgs

      public abstract org.gradle.api.provider.ListProperty<String> 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

      public abstract org.gradle.api.provider.Property<String> getJoularCoreVersion()
      Joular Core release version to download when getJoularCoreBinaryPath() is unset. See Joular Core releases for available versions.
      Returns:
      the Joular Core version property
    • getJoularCoreComponent

      public abstract org.gradle.api.provider.Property<String> getJoularCoreComponent()
      Hardware component to monitor: cpu, gpu, or all.
      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 Java joularcodejava.properties file. Used only when getJoularCodeJavaAgentPath() is also set.
      Returns:
      the Joular Code Java config path property
    • getBaseUrl

      public abstract org.gradle.api.provider.Property<String> getBaseUrl()
      Base URL of the Spring Boot application.
      Returns:
      the base URL property
    • getRequestsPerSecond

      public abstract org.gradle.api.provider.Property<Integer> getRequestsPerSecond()
      Requests per second (passed as RPS environment variable).
      Returns:
      the requests per second property
    • getExternalTrainingCommand

      public abstract org.gradle.api.provider.Property<String> getExternalTrainingCommand()
      Optional external command used as the training workload (e.g. k6 run script.js). The APP_URL environment variable is set to getBaseUrl().
      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 over getExternalTrainingCommand() 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

      public abstract org.gradle.api.provider.Property<Boolean> 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 to getVmPowerFilePath() 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 when getVmMode() is true. Must contain a single float (e.g. 45.2).
      Returns:
      the VM power file path property
    • getWarmupDurationSeconds

      public abstract org.gradle.api.provider.Property<Integer> 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

      public abstract org.gradle.api.provider.Property<Integer> getMeasureDurationSeconds()
      Duration in seconds of the actual measurement window after warmup.
      Returns:
      the measure duration property
    • getStartupTimeoutSeconds

      public abstract org.gradle.api.provider.Property<Integer> getStartupTimeoutSeconds()
      Seconds to wait for the application health endpoint before aborting.
      Returns:
      the startup timeout property
    • getHealthCheckPath

      public abstract org.gradle.api.provider.Property<String> 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

      public abstract org.gradle.api.provider.Property<Double> getThreshold()
      Maximum allowed percentage increase in total energy before the build is failed. For example 10 means a 10 % regression is tolerated.
      Returns:
      the threshold property
    • getFailOnRegression

      public abstract org.gradle.api.provider.Property<Boolean> getFailOnRegression()
      Whether to fail the build on energy regression beyond getThreshold().
      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 during updateEnergyBaseline. When unset, the latest report is discovered automatically under getReportOutputDir().
      Returns:
      the latest report file property
    • getAutoUpdateBaseline

      public abstract org.gradle.api.provider.Property<Boolean> getAutoUpdateBaseline()
      When true, the measurement result is automatically promoted to the baseline after a successful run. Eliminates the need to call updateEnergyBaseline separately.
      Returns:
      the auto-update baseline property
    • getCommitSha

      public abstract org.gradle.api.provider.Property<String> getCommitSha()
      Git commit SHA to record in the baseline when auto-updating.
      Returns:
      the commit SHA property
    • getBranch

      public abstract org.gradle.api.provider.Property<String> getBranch()
      Branch name to record in the baseline when auto-updating.
      Returns:
      the branch property
    • getTimestampReports

      public abstract org.gradle.api.provider.Property<Boolean> getTimestampReports()
      When true, the report output directory gets a timestamp suffix and a latest symlink is created pointing to the most recent run.
      Returns:
      the timestamp reports property
    • getSkip

      public abstract org.gradle.api.provider.Property<Boolean> getSkip()
      When true, plugin execution is skipped entirely.
      Returns:
      the skip property
    • getTopN

      public abstract org.gradle.api.provider.Property<Integer> getTopN()
      Maximum number of methods to display in HTML report tables.
      Returns:
      the topN property
    • getIterations

      public abstract org.gradle.api.provider.Property<Integer> 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

      public abstract org.gradle.api.provider.Property<Integer> getIdleProbeSeconds()
      Seconds to measure idle baseline power before workload (0 = disabled).
      Returns:
      the idle-probe-seconds property