CombiningOperationRequest

public interface CombiningOperationRequest<FileTypeT extends FileSystemLocation>


Summary

Public methods

abstract void
<ArtifactTypeT extends Artifact.Multiple<@NonNull FileTypeT> & Artifact.Transformable> toTransform(
    @NonNull ArtifactTypeT type
)

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

Public methods

toTransform

abstract void <ArtifactTypeT extends Artifact.Multiple<@NonNull FileTypeT> & Artifact.Transformable> toTransform(
    @NonNull ArtifactTypeT type
)

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

Parameters
@NonNull ArtifactTypeT type

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)