CombiningOperationRequest

interface CombiningOperationRequest<FileTypeT : FileSystemLocation>


Summary

Public functions

Unit
<ArtifactTypeT : Artifact.Multiple<FileTypeT> & Artifact.Transformable> toTransform(
    type: ArtifactTypeT
)

Initiates a transform request to a multiple Artifact.Transformable artifact type.

Public functions

toTransform

fun <ArtifactTypeT : Artifact.Multiple<FileTypeT> & Artifact.Transformable> toTransform(
    type: ArtifactTypeT
): Unit

Initiates a transform request to a multiple Artifact.Transformable artifact type.

Parameters
type: ArtifactTypeT

The Artifact of FileTypeT identifying the artifact to transform.

The artifact type must be Artifact.Multiple and Artifact.Transformable.

The implementation of the task must combine all the inputs into a single output. Chained transforms will get a ListProperty containing the single output from the upstream transform.

If some append calls are made on the same artifact type, the first transform will always get the complete list of artifacts irrespective of the timing of the calls.

In the following example, let's take a Task to transform a list of org.gradle.api.file.RegularFile as inputs into a single output:

    abstract class MyTask: DefaultTask() {
@get:InputFiles abstract val inputFiles: ListProperty<RegularFile>
@get:OutputFile abstract val outputFile: RegularFileProperty

@TaskAction fun taskAction() {
... read all inputFiles and write outputFile ...
}
}

An SingleArtifact defined as follows :

    sealed class ArtifactType<T: FileSystemLocation>(val kind: ArtifactKind) {
object MULTIPLE_FILE_ARTIFACT:
ArtifactType<RegularFile>(FILE), Multiple, Transformable
}

You then register the task as follows:

    val taskProvider= projects.tasks.register(MyTask::class.java, "combineTask")
artifacts.use(taskProvider)
.wiredWith(
MyTask::inputFiles,
MyTask::outputFile)
.toTransform(ArtifactType.MULTIPLE_FILE_ARTIFACT)