Stay organized with collections Save and categorize content based on your preferences.


@Incubating interface ArtifactTransformationRequest<TaskT : Task>

When a Directory contains more than one artifact (for example, consider ArtifactType.APK with multiple APKs for different screen densities), this object will abstract away having to deal with BuiltArtifacts and manually load and write the metadata files.

Instead, users can focus on writing transformation code that transform one file at at time into a newer version. It will also provide the ability to use Gradle's WorkQueue to multi-thread the transformations.

Here is an example of a Task copying (unchanged) the APK files from one location to another.

// parameter interface to pass to work items.
interface WorkItemParameters: WorkParameters, Serializable {
   val inputApkFile: RegularFileProperty
   val outputApkFile: RegularFileProperty
// work item that copies one file at a time.
abstract class WorkItem @Inject constructor(
     private val workItemParameters: WorkItemParameters
): WorkAction<WorkItemParameters> {

   override fun execute() {

And the task that wires things together:

abstract class CopyApksTask @Inject constructor(private val workers: WorkerExecutor): DefaultTask() {

abstract val apkFolder: DirectoryProperty

abstract val outFolder: DirectoryProperty

abstract val transformationRequest: Property<ArtifactTransformationRequest<CopyApksTask>>

fun taskAction() {
    workers.noIsolation(),, {
    builtArtifact: BuiltArtifact,
    outputLocation: Directory,
    param: WorkItemParameters ->
      val inputFile = File(builtArtifact.outputFile)


Public methods

abstract Supplier<BuiltArtifacts>
submit(task: TaskT, workQueue: WorkQueue, actionType: Class<out WorkAction<ParamT>>, parameterType: Class<out ParamT>, parameterConfigurator: (builtArtifact: BuiltArtifact, outputLocation: Directory, parameters: ParamT) -> File)

Submit a org.gradle.workers style of WorkAction to process each input BuiltArtifact.

abstract Unit
submit(task: TaskT, transformer: (input: BuiltArtifact) -> File)

Submit a lambda to process each input BuiltArtifact object synchronously.

Public methods


abstract fun <ParamT> submit(
    task: TaskT,
    workQueue: WorkQueue,
    actionType: Class<out WorkAction<ParamT>>,
    parameterType: Class<out ParamT>,
    parameterConfigurator: (builtArtifact: BuiltArtifact, outputLocation: Directory, parameters: ParamT) -> File
): Supplier<BuiltArtifacts> where ParamT : WorkParameters, ParamT : Serializable

Submit a org.gradle.workers style of WorkAction to process each input BuiltArtifact.

task: TaskT The Task initiating the WorkQueue requests.
workQueue: WorkQueue The Gradle WorkQueue instance to use to spawn worker items with.
actionType: Class<out WorkAction<ParamT>> The type of the WorkAction subclass that process that input BuiltArtifact.
parameterType: Class<out ParamT> The type of parameters expected by the WorkAction.
parameterConfigurator: (builtArtifact: BuiltArtifact, outputLocation: Directory, parameters: ParamT) -> File The lambda to configure instances of parameterType for each BuiltArtifact.


abstract fun submit(
    task: TaskT,
    transformer: (input: BuiltArtifact) -> File
): Unit

Submit a lambda to process each input BuiltArtifact object synchronously.