api / org.gradle.workers

Package org.gradle.workers

Types

ForkMode

class ForkMode

Forking mode for workers.

IsolationMode

class IsolationMode

Isolation mode for workers.

WorkerConfiguration

interface WorkerConfiguration : Describable, ActionConfiguration

Represents the configuration of a worker. Used when submitting an item of work to the WorkerExecutor.

 workerExecutor.submit(RunnableWorkImpl.class) { WorkerConfiguration conf -> conf.isolationMode = IsolationMode.PROCESS forkOptions { JavaForkOptions options -> options.maxHeapSize = "512m" options.systemProperty 'some.prop', 'value' options.jvmArgs "-server" } classpath configurations.fooLibrary conf.params = [ "foo", file('bar') ] } 

WorkerExecutionException

open class WorkerExecutionException : DefaultMultiCauseException

Indicates that a failure occurred during execution of work in a worker.

WorkerExecutor

interface WorkerExecutor

Allows work to be submitted for asynchronous execution. This api allows for safe, concurrent execution of work items and enables:

  • Parallel execution of work items within a single task
  • Execution in isolated contexts such as an isolated classloader or even a separate process
  • Safe execution of multiple tasks in parallel
Work should be submitted with a Runnable class representing the implementation of the unit of work and an action to configure the unit of work (via WorkerConfiguration).
 workerExecutor.submit(RunnableWorkImpl.class) { WorkerConfiguration conf -> // Set the isolation mode for the worker conf.isolationMode = IsolationMode.NONE // Set up the constructor parameters for the unit of work conf.params = [ "foo", file('bar') ] }