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 updateEnergyBaselineThe 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 -
Method Summary
Modifier and TypeMethodDescriptionabstract org.gradle.api.file.RegularFilePropertyPath 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.RegularFilePropertyPath to the latest energy report JSON produced bymeasureEnergy.protected abstract org.gradle.api.file.ProjectLayoutGets the project layout.protected abstract org.gradle.api.provider.ProviderFactoryGets the provider factory.abstract org.gradle.api.file.DirectoryPropertyReport output directory where themeasureEnergytask writes its results.abstract org.gradle.api.provider.Property<Boolean>getSkip()Whentrue, the task execution is skipped entirely.voidPromotes 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, usesServiceMethods 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, setImpliesSubProjectsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 bymeasureEnergy. 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 themeasureEnergytask writes its results. Used to locatelatest-energy-report.jsonwhengetLatestReportFile()is not set.- Returns:
- the report output directory property
-
getCommitSha
Git commit SHA to record in the baseline.- Returns:
- the commit SHA property
-
getBranch
Branch name to record in the baseline.- Returns:
- the branch property
-
getSkip
Whentrue, the task execution is skipped entirely.- Returns:
- the skip property
-
updateBaseline
Promotes the most recent measurement as the new energy baseline.- Throws:
IOException- if the baseline cannot be loaded or saved
-