Gradle Tasks & Configuration

Tasks

Task nameDescription
emergeUpload<Variant><Aab|Apk>Builds and uploads to Emerge for size and/or performance analysis.
emergeGeneratePerformanceProjectGenerates a subproject to run custom Emerge performance tests.
emergeLocal<Variant>TestRuns performance tests locally (meant for debugging).
emergeGenerate<Variant>BaselineProfileGenerates a Baseline Profile using Emerge's Launch Booster service.

General

emergeUpload<Variant><Aab|Apk> Task

Added in version 1.0.0.

Builds and uploads to Emerge for size and/or performance analysis. For example:

./gradlew emergeUploadReleaseAab

Using a release variant is recommended, but any variant defined for your application is supported. AAB is recommended but APK is supported as well.

Configuring upload for Continuous Integration (CI)

A few extra arguments are required for pull request diffs (comments & status checks) to work:

  • In the vcsOptions block:
    • sha: SHA hash of the commit that the app was built from.
    • baseSha: SHA hash of the base commit the app was built from. For example, the last commit from main before the current branch was created.
    • branchName: Name of the current git branch.
    • prNumber: Number of the pull request that triggered this build.
    • gitHubOptions block:
      • repoOwner: Name of the GitHub repository owner. Usually an organization.
      • repoName: Name of the GitHub repository.

Optionally, include the following for additional information:

  • buildType: A string indicating what type of build this is. "release" by default if not specified. For example, this could be something like "alpha", "beta" or anything of your choosing depending on the type of build that's being uploaded.

These parameters work with the Emerge GitHub app to find the base build that was already uploaded and associate the analysis results with the right pull request. Here's an example:

plugins {
    // …
    id("com.emergetools.android") version "1.3.0"
}

// …

emerge {
    appProjectPath.set(":app") // The primary subproject for your app.
  
    apiToken.set(System.getenv("EMERGE_API_TOKEN"))

    vcsOptions {
        sha.set("sha")
        baseSha.set("baseSha")
        branchName.set("branchName")
        prNumber.set("prNumber")
          
        gitHubOptions {
            repoOwner.set("YourOrg")
            repoName.set("RepoName")
        }
    }
  
    buildType.set("release") // Optional, customize this based on the build you're uploading.
}
plugins {
    // …
    id "com.emergetools.android" version "1.2.0"
}

// …

emerge {
    appProjectPath = ":app" // The primary subproject for your app.
  
    apiToken = System.getenv("EMERGE_API_TOKEN")

    vcsOptions {
        sha = "sha"
        baseSha = "baseSha"
        branchName = "branchName"
        prNumber = "prNumber"
          
        gitHubOptions {
            repoOwner = "YourOrg"
            repoName = "RepoName"
        }
    }
  
    buildType = "release" // Optional, customize this based on the build you're uploading.
}

Performance Testing

emergeGeneratePerformanceProject Task

Added in version 1.1.0.

Generates a performance testing subproject. This is only necessary for custom performance tests.

First make sure to configure the name of the new project:

emerge {
    // …
  
    performanceProjectPath.set(":performance")
}
emerge {
    // …
  
    performanceProjectPath = ":performance"
}

At this point the project shouldn't exist yet, but the following command will generate it:

./gradlew emergeGeneratePerformanceProject --package com.myapp.performance

For more on custom performance tests see Custom Flow Performance Analysis (Android).

emergeLocalTest Task

Added in version 1.1.0.

Builds, installs and runs Emerge performance tests on a local device. Meant for debugging, does not provide actual performance results.

Your tests must be placed in a performance testing subproject. The subproject path must be configured like so:

emerge {
    // …
  
    performanceProjectPath.set(":performance")
}
emerge {
    // …
  
    performanceProjectPath = ":performance"
}

A device or emulator must be available. Then, to run the tests locally:

./gradlew emergeLocalReleaseTest

Any variant defined for your application is supported. The output will let you know whether tests ran successfully or if certain issues need to be addressed. We recommend making sure tests can run locally before uploading them to Emerge.

For more on custom performance tests see Custom Flow Performance Analysis (Android).

Launch Booster (Baseline Profiles)

emergeGenerate<Variant>BaselineProfile Task

Added in version 1.1.0.

Generates a Baseline Profile using Emerge's Launch Booster service. For example:

./gradlew emergeGenerateReleaseBaselineProfile

Only non-debuggable variants are supported.

For more on baseline profiles see Baseline Profiles (Android).

Disabling Launch Booster

Added in version 1.3.0.

Launch booster automatically creates custom variants for all non-debuggable variants of your app, allowing Emerge to configure the proper proguard/build settings on your behalf with no work or maintenance on your part.

If you wish to not have these variants generated automatically, you can disable Launch Booster with a Gradle property:

emerge {
  ...

  launchBooster {
    enabled.set(false)
  }
}
emerge {
  ...
  
  launchBooster {
    enabled = false
  }
}