Skip to content

Latest commit

 

History

History

transformDirectory

Transform artifacts of type 'Single' and kind 'Directory' with InAndOutDirectoryOperationRequest.toTransform() API

This sample shows how to use the InAndOutDirectoryOperationRequest.toTransform() API on an artifact of type Artifact.Single and Artifact.Transformable.This method is defined in InAndOutDirectoryOperationRequest.

This recipe contains the following directories:

Module Content
build-logic Contains the Project plugin that is the core of the recipe.
app An Android application that has the plugin applied.

The build-logic sub-project contains the CustomPlugin, TransformAssetsTask and CheckAssetsTask classes.

CustomPlugin registers an instance of TransformAssetsTask per variant using InAndOutDirectoryOperationRequest.toTransform() via the code below. This automatically creates a dependency on this task from any task consuming the SingleArtifact.ASSETS artifact.

variant.artifacts.use(transformDebugAssets)
    .wiredWithDirectories(
        TransformAssetsTask::inputDir,
        TransformAssetsTask::outputDir)
    .toTransform(SingleArtifact.ASSETS)

CustomPlugin also registers an instance of the CheckAssetsTask per variant which verifies that the transformed artifact and directory contains the expected data. In this recipe, running this task will also run TransformAssetsTask, because of the dependency on SingleArtifact.ASSETS.

To Run

To execute example you need to enter command:

./gradlew :app:checkDebugAssets