Class UpdateBaselineTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
com.patbaumgartner.greener.gradle.UpdateBaselineTask
All Implemented Interfaces:
Comparable<org.gradle.api.Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.TaskInternal, org.gradle.api.Named, org.gradle.api.plugins.ExtensionAware, org.gradle.api.Task, org.gradle.util.Configurable<org.gradle.api.Task>

@DisableCachingByDefault(because="Baseline update depends on external measurement state") public abstract class UpdateBaselineTask extends org.gradle.api.DefaultTask
Promotes the most recent energy measurement as the new baseline.

Run this task on the main/release branch after confirming the current energy consumption is acceptable:

 ./gradlew updateEnergyBaseline
 
The updated energy-baseline.json should then be committed to source control so that PR builds can compare against it.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.gradle.api.Named

    org.gradle.api.Named.Namer
  • Field Summary

    Fields inherited from interface org.gradle.api.Task

    TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.gradle.api.file.RegularFileProperty
    Path to the JSON baseline file to update.
    abstract org.gradle.api.provider.Property<String>
    Branch name to record in the baseline.
    abstract org.gradle.api.provider.Property<String>
    Git commit SHA to record in the baseline.
    abstract org.gradle.api.file.RegularFileProperty
    Path to the latest energy report JSON produced by measureEnergy.
    protected abstract org.gradle.api.file.ProjectLayout
    Gets the project layout.
    protected abstract org.gradle.api.provider.ProviderFactory
    Gets the provider factory.
    abstract org.gradle.api.file.DirectoryProperty
    Report output directory where the measureEnergy task writes its results.
    abstract org.gradle.api.provider.Property<Boolean>
    When true, the task execution is skipped entirely.
    void
    Promotes the most recent measurement as the new energy baseline.

    Methods inherited from class org.gradle.api.DefaultTask

    compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService

    Methods inherited from class org.gradle.api.internal.AbstractTask

    acceptServiceReferences, appendParallelSafeAction, doNotTrackState, doNotTrackStateIf, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonsNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, restoreOnlyIf, restoreTaskActions, setImpliesSubProjects

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.gradle.api.Task

    doNotTrackState, notCompatibleWithConfigurationCache
  • Constructor Details

    • UpdateBaselineTask

      public UpdateBaselineTask()
  • Method Details

    • getLayout

      @Inject protected abstract org.gradle.api.file.ProjectLayout getLayout()
      Gets the project layout.
      Returns:
      the project layout
    • getProviders

      @Inject protected abstract org.gradle.api.provider.ProviderFactory getProviders()
      Gets the provider factory.
      Returns:
      the provider factory
    • getBaselineFile

      @InputFile @PathSensitive(ABSOLUTE) @Optional public abstract org.gradle.api.file.RegularFileProperty getBaselineFile()
      Path to the JSON baseline file to update.
      Returns:
      the baseline file property
    • getLatestReportFile

      @InputFile @PathSensitive(ABSOLUTE) @Optional public abstract org.gradle.api.file.RegularFileProperty getLatestReportFile()
      Path to the latest energy report JSON produced by measureEnergy. When set, the report at this path is loaded and saved as the new baseline.
      Returns:
      the latest report file property
    • getReportOutputDir

      @Internal public abstract org.gradle.api.file.DirectoryProperty getReportOutputDir()
      Report output directory where the measureEnergy task writes its results. Used to locate latest-energy-report.json when getLatestReportFile() is not set.
      Returns:
      the report output directory property
    • getCommitSha

      @Input @Optional public abstract org.gradle.api.provider.Property<String> getCommitSha()
      Git commit SHA to record in the baseline.
      Returns:
      the commit SHA property
    • getBranch

      @Input @Optional public abstract org.gradle.api.provider.Property<String> getBranch()
      Branch name to record in the baseline.
      Returns:
      the branch property
    • getSkip

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

      public void updateBaseline() throws IOException
      Promotes the most recent measurement as the new energy baseline.
      Throws:
      IOException - if the baseline cannot be loaded or saved