Kotlin Help

Compose compiler options DSL

The Compose compiler Gradle plugin offers a DSL for various compiler options. You can use it to configure the compiler in the composeCompiler {} block of the build.gradle.kts file for the module you're applying the plugin to.

There are two kinds of options you can specify:

  • General compiler settings, which can be disabled or enabled as needed in any given project.

  • Feature flags that enable or disable new and experimental features, which should eventually become part of the baseline.

You can find the list of available general settings and the list of supported feature flags in the Compose compiler Gradle plugin API reference.

Here's an example configuration:

composeCompiler { includeSourceInformation = true featureFlags = setOf( ComposeFeatureFlag.StrongSkipping.disabled(), ComposeFeatureFlag.OptimizeNonSkippingGroups ) }

Purpose and use of feature flags

Feature flags are organized into a separate set of options to minimize changes to top-level properties as new flags are continuously rolled out and deprecated.

To enable a feature flag that is disabled by default, specify it in the set, for example:

featureFlags = setOf(ComposeFeatureFlag.OptimizeNonSkippingGroups)

To disable a feature flag that is enabled by default, call the disabled() function on it, for example:

featureFlags = setOf(ComposeFeatureFlag.StrongSkipping.disabled())

If you are configuring the Compose compiler directly, use the following syntax to pass feature flags to it:

-P plugin:androidx.compose.compiler.plugins.kotlin:featureFlag=<flag name>

See the list of supported feature flags in the Compose compiler Gradle plugin API reference.

Last modified: 11 February 2025