Skip to main content
The Compose Hot Reload Gradle plugin automatically creates several tasks for running and reloading your application. This page provides a complete reference of all available tasks.

Run Tasks

Run tasks launch your application with hot reload enabled.

Standard Run Tasks

These tasks run your application in the foreground (blocking mode):
Task PatternDescriptionExample
hotRunRuns a Kotlin/JVM project./gradlew hotRun
hotRun<Target>Runs a multiplatform project with the specified JVM target./gradlew hotRunJvm
hotRun<Target><Compilation>Runs a specific compilation./gradlew hotRunDesktopMain
For multiplatform projects with the default jvm target, use hotRunJvm. If you’ve defined a custom target name like desktop, the task will be hotRunDesktop.

Async Run Tasks

Async tasks run your application in the background, allowing you to continue using the terminal:
Task PatternDescriptionExample
hotRunAsyncRuns a Kotlin/JVM project in the background./gradlew hotRunAsync
hotRun<Target>AsyncRuns a multiplatform project in the background./gradlew hotRunJvmAsync
Async tasks redirect stdout and stderr to files in the build directory. By default, output goes to build/run/<target>/ directory.

Dev Run Tasks

Dev run tasks allow you to run a specific composable function for quick testing:
./gradlew hotDevJvm --className com.example.ui.MyComponentKt --funName MyComponent
These tasks use the internal DevApplication to display a specific composable without running your full application.

Reload Tasks

Reload tasks recompile changed code and apply it to running applications. These only work in explicit mode (not with --autoReload).
TaskDescriptionExample
reloadReloads all currently running applications./gradlew reload
hotReload<Target><Compilation>Reloads applications using a specific source set./gradlew hotReloadJvmMain
Reload tasks cannot be used with --autoReload or --auto command-line arguments. In auto mode, reloading happens automatically.

How Reload Tasks Work

1

Detect running applications

The task checks for running applications by looking for PID files in the build directory.
2

Recompile changed code

Only the modified source files are recompiled, making the process fast.
3

Send reload request

The compiled classes are sent to the running application via the orchestration protocol.
4

Apply changes

The JetBrains Runtime’s enhanced class redefinition applies the changes without restarting.

Snapshot Tasks

Snapshot tasks are internal tasks that create snapshots of the runtime classpath. They run automatically as dependencies of other tasks:
Task PatternDescription
hotSnapshot<Target><Compilation>Creates a classpath snapshot for change detection
You typically don’t need to run snapshot tasks manually. They’re executed automatically when you run hot reload tasks.

Task Naming Conventions

Compose Hot Reload follows a consistent naming pattern for all tasks:

Pattern: hot<Action><Target><Compilation>

  • Action: Run, Reload, Snapshot, Dev
  • Target: The name of your JVM target (e.g., Jvm, Desktop)
  • Compilation: Usually Main for the main source set

Examples

For a multiplatform project with a jvm target:
build.gradle.kts
kotlin {
    jvm()
}
Generated tasks:
  • hotRunJvm - Run the application
  • hotRunJvmAsync - Run in background
  • hotReloadJvmMain - Reload the jvmMain source set
  • hotSnapshotJvmMain - Create a classpath snapshot
For a custom target name:
build.gradle.kts
kotlin {
    jvm("desktop")
}
Generated tasks:
  • hotRunDesktop - Run the application
  • hotRunDesktopAsync - Run in background
  • hotReloadDesktopMain - Reload the desktopMain source set
  • hotSnapshotDesktopMain - Create a classpath snapshot

Task Configuration

You can configure hot reload tasks in your build script. See the examples below:

Configure All ComposeHotRun Tasks

build.gradle.kts
tasks.withType<ComposeHotRun>().configureEach {
    mainClass.set("com.example.MainKt")
}

Configure a Specific Task

build.gradle.kts
tasks.named<ComposeHotRun>("hotRunJvm") {
    mainClass.set("com.example.MainKt")
    jvmArgs = listOf("-Xmx2G")
}

Create a Custom Run Task

You can register custom run tasks:
build.gradle.kts
tasks.register<ComposeHotRun>("runMyApp") {
    mainClass.set("com.example.MainKt")
    // Additional configuration
}
See Configuration for more details on configuring tasks.

Task Groups

Compose Hot Reload tasks are organized into groups for easier discovery:
  • Compose Hot Reload: Run - All run tasks (blocking and async)
  • Compose Hot Reload: Other - Reload and utility tasks
You can see these groups when running ./gradlew tasks --group="Compose Hot Reload: Run".

Task Dependencies

Hot reload tasks have the following dependency chain:
hotRunJvm
  └─> hotSnapshotJvmMain
        └─> compileKotlinJvm
              └─> [standard Kotlin compilation tasks]
When you run a hot reload task:
  1. Kotlin compilation runs first
  2. A classpath snapshot is created
  3. The application launches with hot reload enabled

Common Usage Patterns

Run and Reload Workflow

Terminal 1: Run the application
./gradlew :app:hotRunJvm
Terminal 2: Reload when ready
./gradlew :app:reload

Multiple Modules

If you have multiple modules with JVM targets, each gets its own set of tasks:
# Module 1
./gradlew :module1:hotRunJvm

# Module 2 (in another terminal)
./gradlew :module2:hotRunJvm

Troubleshooting

Task Not Found

If a hot reload task doesn’t exist:
  1. Ensure the plugin is applied to the module:
    plugins {
        id("org.jetbrains.compose.hot-reload")
    }
    
  2. Verify you have a JVM target:
    kotlin {
        jvm()
    }
    
  3. Sync your Gradle project

Task Fails to Start

If the task fails with a JVM error:
  1. Ensure you have JetBrains Runtime installed (or enable auto-provisioning)
  2. Check that your project targets Java 21 or earlier
  3. Review the prerequisites

Next Steps

Build docs developers (and LLMs) love