Class Task
- Direct Known Subclasses:
AbstractGitTask,BarrierTask,CopyTask,DecompileTask,DetectChangesTask,DiscordReportTask,DownloadTask,GenerateComparisonsTask,GenerateGradleProjectTask,GenerateRootProjectTask,PrepareToolTask,RemapperTask,SetupGitRepoTask,SetupJdkTask,UnzipTask
Tasks automatically declare dependencies between each-other by consuming their outputs as inputs, or deriving their own output from another tasks output. Note: Task dependencies are collected when a dependent task is scheduled for execution.
Tasks may declare themselves as cacheable, using a selection of their inputs and outputs as the cache value, if the cache value matches the previous run, it will not be re-run. Note: It's important to ensure your outputs are included in the cache, otherwise your task may not re-run when it's missing.
Tasks may declare 'inner' tasks via declareCompositeTask(net.javasauce.ss.util.task.Task), these tasks copy any
explicit dependencies their outer has/will have, and are marked as explicit dependencies of their outer.
Created by covers1624 on 6/24/25.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final <T> TaskOutput<T> computedOutput(String name) Create a new output for your task.protected voiddeclareCompositeTask(Task task) Declare the given task execute before this task.voidMark this task as requiring the provided tasks, without declaring any IO dependencies.voidMark this task as requiring the provided tasks, without declaring any IO dependencies.protected abstract voidexecute()Called to execute your task actions.final CompletableFuture<Task> Resolve this tasks dependencies and return a future for the execution of this task.final StringgetName()protected final <T> TaskInput<T> Create a new input for your task.protected final <T> TaskInput<T> Create a new input for your task, with the provided initial value.protected final <T> TaskInput.Collection<T> inputCollection(String name) Create a new collection input for your task.optionalInput(String name) Create a new optional input for your task.protected final <T> TaskOutput<T> Create a new output for your task.static voidSchedule the given tasks and wait for them to complete.static voidSchedule the given tasks and wait for them to complete.protected final voidwithCaching(TaskOutput<Path> cacheNextTo, String cacheSuffix, Consumer<TaskCacheBuilder> configure) Enable caching for your task.protected final voidwithCaching(TaskOutput<Path> cacheNextTo, Consumer<TaskCacheBuilder> cons) Enable caching for your task.
-
Constructor Details
-
Task
- Parameters:
name- The name for this task, used for logging.executor- The executor to run this task on. If you don't know what to provide you can useForkJoinPool.commonPool(), for the built-in executor. Providing your task a specific executor can be used to create execution groups, for example, using a single-thread executor can ensure only one instance of your task is executed at a time.
-
-
Method Details
-
runTasks
Schedule the given tasks and wait for them to complete.- Parameters:
tasks- The tasks to run.
-
runTasks
Schedule the given tasks and wait for them to complete.- Parameters:
tasks- The tasks to run.
-
withCaching
Enable caching for your task.- Parameters:
cacheNextTo- The output to store the cache file next to.cons- The function to configure the cache with your cache inputs/outputs.
-
withCaching
protected final void withCaching(TaskOutput<Path> cacheNextTo, String cacheSuffix, Consumer<TaskCacheBuilder> configure) Enable caching for your task.- Parameters:
cacheNextTo- The output to store the cache file next to.cacheSuffix- A suffix on the cache name, this can be used to distinguish between .sha1 files. // TODO perhaps we change the suffix to always be '_task.sha1'configure- The function to configure the cache with your cache inputs/outputs.
-
input
Create a new input for your task. You must set a value before the task executes.- Parameters:
name- The name for your input. Used in logging/errors.- Returns:
- A new input for your task, a value must be set.
-
input
Create a new input for your task, with the provided initial value.- Parameters:
name- The name for your input. Used in logging/errors.- Returns:
- A new input for your task.
-
optionalInput
Create a new optional input for your task. The default value is set to empty.- Parameters:
name- The name for your input. Used in logging/errors.- Returns:
- A new input for your task.
-
inputCollection
Create a new collection input for your task. The default value is set to an empty list.- Parameters:
name- The name for your input. Used in logging/errors.- Returns:
- A new input for your task.
-
output
Create a new output for your task. You must set a value before executing the task.- Parameters:
name- The name for your output. Used in logging/errors.- Returns:
- A new output for your task.
-
computedOutput
Create a new output for your task. You must set a value for this output before your task finishes executing.- Parameters:
name- The name for your output. Used in logging/errors.- Returns:
- A new output for your task.
-
dependsOn
Mark this task as requiring the provided tasks, without declaring any IO dependencies.- Parameters:
tasks- The tasks to depend on.
-
dependsOn
Mark this task as requiring the provided tasks, without declaring any IO dependencies.- Parameters:
tasks- The tasks to depend on.
-
declareCompositeTask
Declare the given task execute before this task.The given task will copy all explicit dependencies of this task, however, will not automatically copy any implicit dependencies handed through IO variables. The given task will need to either derive its own inputs from the inputs of the outer, or copy the outers inputs.
-
getFuture
Resolve this tasks dependencies and return a future for the execution of this task.- Returns:
- The future.
-
execute
Called to execute your task actions.- Throws:
Throwable
-
getName
-