InAndOutFileOperationRequest

Added in 4.2.0

interface InAndOutFileOperationRequest


Operations performed by a Task with a single RegularFile output.

Task is consuming existing version of the target SingleArtifact and producing a new version.

Summary

Public functions

Unit
<ArtifactTypeT : Artifact.Single<RegularFile> & Artifact.Transformable> toTransform(
    type: ArtifactTypeT
)

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

InAndOutFileOperationRequest

Sets the output file name for the transformed artifact.

Public functions

toTransform

Added in 7.0.0
fun <ArtifactTypeT : Artifact.Single<RegularFile> & Artifact.Transformable> toTransform(
    type: ArtifactTypeT
): Unit

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

Parameters
type: ArtifactTypeT

The Artifact identifying the artifact to transform. The Artifact's Artifact.kind must be Artifact.FILE.

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

As an example, let's take a Task transforming an input org.gradle.api.file.RegularFile into an output:

    abstract class MyTask: DefaultTask() {
@get:InputFile abstract val inputFile: RegularFileProperty
@get:OutputFile abstract val outputFile: RegularFileProperty

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

An ArtifactType defined as follows:

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

You can register a transform to the collection of org.gradle.api.file.RegularFile.

    val taskProvider= projects.tasks.register(MyTask::class.java, "transformTask")
artifacts.use(taskProvider)
.wiredWithFiles(
MyTask::inputFile,
MyTask::outputFile)
.toTransform(ArtifactType.SINGLE_FILE_ARTIFACT)

withName

Added in 8.4.0
fun withName(name: String): InAndOutFileOperationRequest

Sets the output file name for the transformed artifact.

Parameters
name: String

file name in the output folder.