InAndOutDirectoryOperationRequest
interface InAndOutDirectoryOperationRequest<TaskT : Task>
com.android.build.api.artifact.InAndOutDirectoryOperationRequest |
Summary
Public methods |
|
---|---|
abstract Unit |
toTransform(type: ArtifactTypeT) Initiates a transform request to a single Artifact.Transformable artifact type. |
abstract ArtifactTransformationRequest<TaskT> |
toTransformMany(type: ArtifactTypeT) Initiates a transform request to a single Artifact.Transformable artifact type that can contain more than one artifact. |
Public methods
toTransform
abstract fun <ArtifactTypeT> toTransform(type: ArtifactTypeT): Unit where ArtifactTypeT : Artifact.Single<Directory>, ArtifactTypeT : Artifact.Transformable
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) |
toTransformMany
abstract fun <ArtifactTypeT> toTransformMany(type: ArtifactTypeT): ArtifactTransformationRequest<TaskT> where ArtifactTypeT : Artifact.Single<Directory>, ArtifactTypeT : Artifact.ContainsMany
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. |
Return | |
---|---|
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) } |