Skip to main content
You can run your Compose application with hot reload directly from the command line using Gradle tasks. This is especially useful for automated workflows, CI/CD pipelines, or when working without an IDE.

Run Tasks

The Compose Hot Reload plugin automatically creates run tasks when you apply the plugin:
./gradlew :app:hotRunJvm

Task Naming

The task name depends on your project type and JVM target name:
  • Multiplatform projects: :hotRunJvm (or :hotRun<TargetName> for custom target names)
  • Kotlin/JVM projects: :hotRun

Custom Target Names

If you’ve defined a custom JVM target name in your Kotlin Multiplatform configuration, the task name reflects that target:
build.gradle.kts
kotlin {
    jvm("desktop")
}
For this configuration, the task would be :hotRunDesktop.

Reload Modes

Compose Hot Reload supports two modes for applying changes:
In explicit mode, you manually trigger reloads when you’re ready:
  1. Start your application:
    ./gradlew :app:hotRunJvm
    
  2. Make your code changes
  3. In a separate terminal, trigger a reload:
    ./gradlew :app:reload
    
Your changes are recompiled and applied to the running application.
This is the recommended mode as it gives you control over when to apply changes.

Command-Line Arguments

You can customize the run tasks with these command-line arguments:
ArgumentDescriptionExample
--mainClass <FQN>Specify the main class to run./gradlew :app:hotRunJvm --mainClass com.example.MainKt
--autoReloadEnable automatic reloading./gradlew :app:hotRunJvm --autoReload
--autoEnable automatic reloading (short form)./gradlew :app:hotRunJvm --auto
--no-autoReloadDisable automatic reloading./gradlew :app:hotRunJvm --no-autoReload
--no-autoDisable automatic reloading (short form)./gradlew :app:hotRunJvm --no-auto

Specifying the Main Class

If your project has multiple entry points, you can specify which one to run:
./gradlew :app:hotRunJvm --mainClass com.example.MainKt
Alternatively, configure it in your build script. See Configuration for details.

Reload Tasks (Explicit Mode Only)

When running in explicit mode, use reload tasks to apply your changes:
./gradlew :app:reload
You cannot use reload tasks with --autoReload or --auto flags. Auto mode handles reloading automatically.

Available Reload Tasks

  • reload: Reloads all currently running applications in the project
  • hotReload<Target><Compilation>: Reloads applications using a specific source set (e.g., hotReloadJvmMain)
See Gradle Tasks Reference for the complete list of tasks.

Async Run Tasks

For advanced use cases, async variants of the run tasks are available:
./gradlew :app:hotRunJvmAsync
Async tasks launch the application in the background and immediately return, allowing you to continue using the same terminal. The application’s output is redirected to log files in the build directory.

Output Redirection

By default, async tasks write output to:
  • stdout: build/run/<target>/hotRunJvm.stdout.txt
  • stderr: build/run/<target>/hotRunJvm.stderr.txt
You can customize these locations:
./gradlew :app:hotRunJvmAsync --stdout=custom.log --stderr=errors.log

Examples

Basic Usage

Start your application with hot reload:
./gradlew :composeApp:hotRunJvm
Make changes, then reload:
./gradlew :composeApp:reload

Auto Reload Mode

Run with automatic reload on file changes:
./gradlew :composeApp:hotRunJvm --auto

Custom Main Class

Run a specific main class:
./gradlew :app:hotRunJvm --mainClass com.myapp.AlternativeMainKt

Background Execution

Launch in the background:
./gradlew :app:hotRunJvmAsync
View the output:
tail -f build/run/jvm/hotRunJvm.stdout.txt

Stopping the Application

When running in normal (blocking) mode:
  • Press Ctrl+C in the terminal to stop the application
When running in async mode:
  • The application runs as a separate process
  • Running the async task again will automatically stop the previous instance before starting a new one
  • Alternatively, find and kill the process manually using the PID stored in build/run/<target>/<target>.pid

Next Steps

Build docs developers (and LLMs) love