gradle
8.4

# WorkAction

interface WorkAction<T : WorkParameters?>(source)

Represents the implementation of a unit of work to be used when submitting work to the WorkerExecutor.

A work action implementation is an abstract class implementing the execute method. A minimal implementation may look like this:

    import org.gradle.workers.WorkParameters;

    public abstract class MyWorkAction implements WorkAction<WorkParameters.None> {
        private final String greeting;

        @Inject
        public MyWorkAction() {
            this.greeting = "hello";
        }

        @Override
        public void execute() {
            System.out.println(greeting);
        }
    }

Content copied to clipboard
Implementations of WorkAction are subject to the following constraints:

- Do not implement getParameters in your class, the method will be implemented by Gradle.
- Constructors must be annotated with Inject.

#### Parameters

<T>

Parameter type for the work action. Should be WorkParameters.None if the action does not have parameters.

## Functions

execute
Link copied to clipboard
abstract fun execute()
The work to perform when this work item executes.
getParameters
Link copied to clipboard
@Inject
abstract fun getParameters(): T
The parameters associated with a concrete work item.