Skip to content

Common Tasks

List Variants

This Gradle task generates a JSON file containing information about the project's dependency variants and fallback variants.

Steps:

  1. The task scans the project's tasks for those with names containing the ExtractDependencies postfix.
  2. It extracts the relevant variant names and writes them to a dependency_variants.json file in the plugins-dependencies directory under the app's build directory.
  3. It retrieves missing dimension strategies and their fallback values from the Android product flavors and writes them to a fallback_variants.json file in the same directory.

Example: dependency_variants.json

json
{
  "example-one-plugin": ["debug", "release", "benchmark"],
  "example-two-plugin": ["debug", "release", "benchmark"],
  "hello-world-plugin": ["debug", "release", "benchmark"],
  "sample-app": ["debug", "release", "benchmark"]
}

Example: fallback_variants.json

json
{
  "australia": "withGooglePay",
  "bahrain": "withMauth",
  "bangladesh": "withMauth",
  "bermuda": "withMauth",
  "chiiom": "withMauth",
  "china": "withMauth",
  "egypt": "withMauth",
  "expat": "withMauth",
  "hongkong": "withMauth",
  "india": "withMauth",
  "indonesia": "withMauth",
  "macau": "withMauth",
  "malaysia": "withMauth",
  "malta": "withMauth",
  "mexico": "withMauth",
  "msb": "withMauth",
  "philippines": "withMauth",
  "qatar": "withMauth",
  "singapore": "withMauth",
  "srilanka": "withNone",
  "taiwan": "withMauth",
  "uae": "withMauth",
  "uk": "withMauth",
  "us": "withMauth",
  "vietnam": "withMauth"
}

Output Location

The generated JSON files are located at build/plugins-dependencies under the app module.

Command to Run

Run the task locally using the following command:

shell
./gradlew listVariants

Extract Dependencies

This Gradle task extracts dependencies for a specific variant of the project.

Steps:

  1. The task uses the variantNameProperty to identify the variant and retrieves the associated dependencies.
  2. It copies the extracted .aar files into the directory located at build/plugins-dependencies/zip under the app module.

Example: Schema Structure

The extracted dependencies are organized in a structured location for further use:

Extracted dependencies structure

Command to Run

Run the task locally using the following command:

shell
./gradlew :<module>:<variantName>ExtractDependencies

Recommendation

Instead of running this standalone task for the app module, it is recommended to run the Extract All Dependencies task.


Extract All Dependencies

This task triggers the Extract Dependencies task for the app module and its submodules that have applied the PH Gradle Plugin.

Command to Run

Run the task locally using the following command:

shell
./gradlew <appVariantName>ExtractAllDependencies

:::note

Before running this task, you need to run the List Variants task.

:::