Skip to content

Files

Latest commit

b469dc7 · Feb 6, 2025

History

History
This branch is 1 commit ahead of, 1 commit behind agp-8.8.

createSingleArtifact

Creating a single artifact

This recipe shows how to add a task per variant to create a SingleArtifact. This recipe uses SingleArtifact.MERGED_MANIFEST as an example, but the code is similar for other SingleArtifact types.

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 ProduceManifestTask classes.

CustomPlugin registers an instance of the ProduceManifestTask task per variant and use TaskBasedOperation::wiredWith and OutOperationRequest::toCreate api to wire this task's output to create SingleArtifact.MERGED_MANIFEST. It also registers a VerifyManifestTask that does a simple verification that the SingleArtifact.MERGED_MANIFEST is replaced by the output of ProduceManifestTask task.

Please note that the exact usage in this recipe is just for demonstrating the OutOperationRequest::toCreate API. There are better ways to control the manifest content per variant, and this API should only be used for the MERGED_MANIFEST artifact in rare cases.

To run the recipe : gradlew :app:verifyDebugManifest