Skip to content

Latest commit

 

History

History

appendToMultipleArtifact

Appending a generated directory to an instance of MultipleArtifact

This recipe shows how to add a generated directory to an instance of MultipleArtifact. This recipe uses MultipleArtifact.NATIVE_DEBUG_METADATA as an example, but the code is similar for the other MultipleArtifact types that implement Appendable.

Note: for an example of adding a static directory to an instance of MultipleArtifact, see the addMultipleArtifact recipe.

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, GenerateNativeDebugMetadataTask, and CheckBundleTask classes.

CustomPlugin registers an instance of GenerateNativeDebugMetadataTask per variant and appends its output directory to the MultipleArtifact.NATIVE_DEBUG_METADATA artifacts as shown below. This automatically creates a dependency on this task from any task consuming the MultipleArtifact.NATIVE_DEBUG_METADATA artifacts.

variant.artifacts.use(generateNativeDebugMetadataTask)
    .wiredWith(GenerateNativeDebugMetadataTask::output)
    .toAppendTo(MultipleArtifact.NATIVE_DEBUG_METADATA)

CustomPlugin also registers an instance of the CheckBundleTask per variant which verifies that the app bundle contains the expected native debug metadata entries.

To run the recipe : gradlew checkDebugBundle