Skip to content

Latest commit

 

History

History

addMultipleArtifact

Adding a static directory to an instance of MultipleArtifact

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

Note: for an example of adding a generated directory to an instance of MultipleArtifact, see the appendToMultipleArtifact 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 and CheckBundleTask classes.

CustomPlugin adds the native-debug-metadata/extra directory to the MultipleArtifact.NATIVE_DEBUG_METADATA artifacts like so:

variant.artifacts
    .add(
        MultipleArtifact.NATIVE_DEBUG_METADATA,
        project.layout.projectDirectory.dir("native-debug-metadata/extra")
    )

CustomPlugin also registers an instance of the CheckBundleTask per variant and sets its input directory via variant.artifacts.get(SingleArtifact.BUNDLE), which automatically adds a dependency on the task that produces SingleArtifact.BUNDLE.

CheckBundleTask verifies that the app bundle contains the expected native debug metadata entries.

To run the recipe : gradlew checkDebugBundle