Skip to content

Gradle Plugin

Using the Gradle Plugin, you can fully automate the process of generating the report without any overhead.
This Gradle plugin takes care of generating raw compose metrics and report from the Compose compiler and then generates the beautified report from them.

This plugin has support for Android projects and Kotlin Multiplatform projects.

✅ Apply the plugin

Apply the plugin to the module in which compose is enabled.

Info

Check the latest plugin release: Gradle Plugin

Using the plugins DSL:

build.gradle
plugins {
  id "dev.shreyaspatil.compose-compiler-report-generator" version "1.4.0"
}
build.gradle.kts
plugins {
  id("dev.shreyaspatil.compose-compiler-report-generator") version "1.4.0"
}    

Using legacy plugin application:

Add this to top project level build.gradle

build.gradle
buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "dev.shreyaspatil.compose-compiler-report-generator:gradle-plugin:1.4.0"
  }
}

Apply in the module level project:

apply plugin: "dev.shreyaspatil.compose-compiler-report-generator"
build.gradle.kts
buildscript {
  repositories {
    maven {
      url = uri("https://plugins.gradle.org/m2/")
    }
  }
  dependencies {
    classpath("dev.shreyaspatil.compose-compiler-report-generator:gradle-plugin:1.4.0")
  }
}

Apply in the module level project:

apply(plugin = "dev.shreyaspatil.compose-compiler-report-generator")

💫 Sync the project

Once plugin is applied, sync the project. After the project is synced, tasks for generating compose report will be generated for the variants and flavors used in the project.

Example

For Kotlin Multiplatform project, tasks will be generated for the platform modules and build types.

🪄 Generate report

Run the Gradle task (or directly run the task from tasks pane available on the right side of IDE)

./gradlew :app:releaseComposeCompilerHtmlReport

If report is generated successfully, the path to report will be logged in the console

Example (Console output)

Compose Compiler report is generated: .../noty-android/app/composeapp/build/compose_report/index.html

BUILD SUCCESSFUL in 58s
1 actionable task: 1 executed

⚙️ Configure parameters for plugin (Optional)

If you have to configure plugin parameters manually (which is completely optional), it can be configured as follows:

build.gradle
htmlComposeCompilerReport {
    // Enables metrics generation from the compose compiler
    enableMetrics = true/false // Default: `true`

    // Enables report generation from the compose compiler
    enableReport = true/false // Default: `true`

    // Sets the name for a report
    name = "Report Name" // Default: Module name

    // Output directory where report will be generated
    outputDirectory = layout.buildDirectory.dir("custom_dir").get().asFile // Default: module/buildDir/compose_report

    // Whether to include stable composable functions in the final report or not.
    includeStableComposables = true/false // Default: true

    // Whether to include stable classes in the final report or not.
    includeStableClasses = true/false // Default: true

    // Whether to include the ALL classes in the final report or not.
    includeClasses = true/false // Default: true

    // ONLY show unstable composables in the report without stats and classes
    showOnlyUnstableComposables = true/false // Default: false
}
build.gradle.kts
htmlComposeCompilerReport {
    // Enables metrics generation from the compose compiler
    enableMetrics.set(true/false) // Default: `true`

    // Enables report generation from the compose compiler
    enableReport.set(true/false) // Default: `true`

    // Sets the name for a report
    name.set("Report Name") // Default: Module name

    // Output directory where report will be generated
    outputDirectory.set(layout.buildDirectory.dir("custom_dir").get().asFile) // Default: module/buildDir/compose_report

    // Whether to include stable composable functions in the final report or not.
    includeStableComposables.set(true/false) // Default: true

    // Whether to include stable classes in the final report or not.
    includeStableClasses.set(true/false) // Default: true

    // Whether to include the ALL classes in the final report or not.
    includeClasses.set(true/false) // Default: true

    // ONLY show unstable composables in the report without stats and classes
    showOnlyUnstableComposables.set(true/false) // Default: false
}