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 Pattern | Description | Example |
|---|---|---|
hotRun | Runs 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 Pattern | Description | Example |
|---|---|---|
hotRunAsync | Runs a Kotlin/JVM project in the background | ./gradlew hotRunAsync |
hotRun<Target>Async | Runs 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: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).
| Task | Description | Example |
|---|---|---|
reload | Reloads all currently running applications | ./gradlew reload |
hotReload<Target><Compilation> | Reloads applications using a specific source set | ./gradlew hotReloadJvmMain |
How Reload Tasks Work
Detect running applications
The task checks for running applications by looking for PID files in the build directory.
Send reload request
The compiled classes are sent to the running application via the orchestration protocol.
Snapshot Tasks
Snapshot tasks are internal tasks that create snapshots of the runtime classpath. They run automatically as dependencies of other tasks:| Task Pattern | Description |
|---|---|
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
Mainfor the main source set
Examples
For a multiplatform project with ajvm target:
build.gradle.kts
hotRunJvm- Run the applicationhotRunJvmAsync- Run in backgroundhotReloadJvmMain- Reload the jvmMain source sethotSnapshotJvmMain- Create a classpath snapshot
build.gradle.kts
hotRunDesktop- Run the applicationhotRunDesktopAsync- Run in backgroundhotReloadDesktopMain- Reload the desktopMain source sethotSnapshotDesktopMain- 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
Configure a Specific Task
build.gradle.kts
Create a Custom Run Task
You can register custom run tasks:build.gradle.kts
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
./gradlew tasks --group="Compose Hot Reload: Run".
Task Dependencies
Hot reload tasks have the following dependency chain:- Kotlin compilation runs first
- A classpath snapshot is created
- The application launches with hot reload enabled
Common Usage Patterns
Run and Reload Workflow
- Separate Terminals
- Single Terminal (Async)
- Auto Mode
Terminal 1: Run the applicationTerminal 2: Reload when ready
Multiple Modules
If you have multiple modules with JVM targets, each gets its own set of tasks:Troubleshooting
Task Not Found
If a hot reload task doesn’t exist:-
Ensure the plugin is applied to the module:
-
Verify you have a JVM target:
- Sync your Gradle project
Task Fails to Start
If the task fails with a JVM error:- Ensure you have JetBrains Runtime installed (or enable auto-provisioning)
- Check that your project targets Java 21 or earlier
- Review the prerequisites
Next Steps
- Learn how to configure tasks in your build script
- Explore system properties for advanced configuration
- Check out CLI usage examples