Skip to main content

Overview

The composeHotReload extension is automatically created when the plugin is applied. It provides project-wide configuration for Compose Hot Reload. Extension Name: composeHotReload Extension Class: ComposeHotReloadExtension Package: org.jetbrains.compose.reload.gradle

Basic Usage

build.gradle.kts
composeHotReload {
    // Configuration options
}

Extension Class

open class ComposeHotReloadExtension(internal val project: Project)
The extension is created with a reference to the Gradle project.

Configuration

Currently, the extension class is minimal and serves as a placeholder for future configuration options. Most configuration is done through:
  1. Gradle Properties - Set in gradle.properties or via command line
  2. Task Configuration - Configure individual tasks directly
  3. Environment Variables - For IDE integration

Accessing the Extension

You can access the extension in your build script:
build.gradle.kts
val hotReload = extensions.getByType<ComposeHotReloadExtension>()
Or use the DSL:
build.gradle.kts
composeHotReload {
    // Future configuration options will be available here
}
While the extension itself doesn’t have configuration properties yet, the plugin respects several Gradle properties:

Runtime Dependencies

compose.reload.autoRuntimeDependencies
boolean
default:"true"
Automatically add hot reload runtime dependencies to dev compilations.Set in gradle.properties:
compose.reload.autoRuntimeDependencies=false

Auto Reload Mode

compose.reload.gradle.build.continuous
boolean
default:"false"
Enable continuous build mode for automatic recompilation.
compose.reload.gradle.build.continuous=true

Output Redirection

compose.reload.stdout.file
string
Custom file path for stdout redirection in async run tasks.
compose.reload.stdout.file=/tmp/app.log
compose.reload.stderr.file
string
Custom file path for stderr redirection in async run tasks.
compose.reload.stderr.file=/tmp/app.err
compose.reload.stdin.file
string
Custom file path for stdin in async run tasks.
compose.reload.stdin.file=/tmp/app.in

Debugging

compose.reload.subprocess.debugging.enabled
boolean
default:"false"
Enable subprocess debugging support.
compose.reload.subprocess.debugging.enabled=true
COMPOSE_RELOAD_INTELLIJ_DEBUGGER_DISPATCH_PORT
string
Environment variable for IntelliJ debugger integration.Set by the IDE when debugging is enabled.

Project Extension Property

The plugin also adds a isHotReloadBuild property to the Project object:
val Project.isHotReloadBuild: Boolean
This property is true when the current build was triggered by Compose Hot Reload for recompilation.

Usage

build.gradle.kts
tasks.register("checkBuildType") {
    doLast {
        if (project.isHotReloadBuild) {
            println("This is a hot reload build")
        } else {
            println("This is a regular build")
        }
    }
}
This can be useful for:
  • Skipping certain tasks during hot reload builds
  • Enabling faster incremental compilation
  • Customizing build behavior for development

Future Configuration

The extension is designed to be extended with configuration options in future releases. Potential future additions may include:
  • Hot reload behavior settings
  • Custom compilation targets
  • Performance tuning options
  • Advanced debugging configuration

Example: Complete Configuration

build.gradle.kts
plugins {
    kotlin("jvm")
    id("org.jetbrains.compose")
    id("org.jetbrains.compose.hot-reload")
}

composeHotReload {
    // Extension configuration (currently minimal)
}

// Configure hot reload via tasks
tasks.withType<ComposeHotRun> {
    // Default main class for all hot run tasks
    mainClass.convention("com.example.MainKt")
    
    // Default JVM args
    jvmArgs("-Xmx2g", "-XX:+UseG1GC")
}

// Configure hot reload via properties
// (in gradle.properties)
// compose.reload.autoRuntimeDependencies=true

Internal API

The extension has an internal project property:
internal val project: Project
This is used internally by the plugin and should not be accessed by build scripts.

Build docs developers (and LLMs) love