Stay organized with collections
Save and categorize content based on your preferences.
InAndOutDirectoryOperationRequest
interface InAndOutDirectoryOperationRequest<TaskT : Task>
Summary
Public functions
fun <ArtifactTypeT : Artifact.Single<Directory> & 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.DIRECTORY
The artifact type must be Artifact.Single and Artifact.Transformable .
Let's take a Task transforming an input org.gradle.api.file.Directory into an output:
abstract class MyTask: DefaultTask() { @get:InputFiles abstract val inputDir: DirectoryProperty @get:OutputDirectory abstract val outputDir: DirectoryProperty
@TaskAction fun taskAction() { ... read inputFile and write outputFile ... } }
An ArtifactType defined as follows :
sealed class ArtifactType<T: FileSystemLocation>(val kind: ArtifactKind) { object SINGLE_DIR_ARTIFACT: ArtifactType<Directory>(DIRECTORY), 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) .wiredWithDirectories( MyTask::inputFile, MyTask::outputFile) .toTransform(ArtifactType.SINGLE_DIR_ARTIFACT)
|
fun <ArtifactTypeT : Artifact.Single<Directory> & Artifact.ContainsMany> toTransformMany(
type: ArtifactTypeT
): ArtifactTransformationRequest<TaskT>
Initiates a transform request to a single Artifact.Transformable
artifact type that can contain more than one artifact.
Parameters |
type: ArtifactTypeT |
The Artifact of the Directory identifying the artifact to transform.
|
Returns |
ArtifactTransformationRequest<TaskT> |
ArtifactTransformationRequest that will allow processing of individual artifacts located in the input directory.
The artifact type must be Artifact.Single , Artifact.Transformable , and Artifact.ContainsMany .
For 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 inputFolder: DirectoryProperty @get:OutputFile abstract val outputFolder: DirectoryProperty @Internal abstract Property<ArtifactTransformationRequest<MyTask>> getTransformationRequest()
@TaskAction fun taskAction() { transformationRequest.get().submit( ... submit a work item for each input file ... ) } }
You then register the task as follows:
val taskProvider= projects.tasks.register(MyTask::class.java, "combineTask") val transformationRequest = artifacts.use(taskProvider) .wiredWith( MyTask::inputFolder, MyTask::outputFolder) .toTransformMany(ArtifactType.APK) taskProvider.configure { task -> task.getTransformationRequest().set(transformationRequest) }
|
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2022-08-25 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{
"lastModified": "Last updated 2022-08-25 UTC.",
"confidential": False
}