Run Tasks
The Compose Hot Reload plugin automatically creates run tasks when you apply the plugin: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
:hotRunDesktop.
Reload Modes
Compose Hot Reload supports two modes for applying changes:- Explicit Mode (Default)
- Auto Mode
In explicit mode, you manually trigger reloads when you’re ready:
-
Start your application:
- Make your code changes
-
In a separate terminal, trigger a reload:
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:| Argument | Description | Example |
|---|---|---|
--mainClass <FQN> | Specify the main class to run | ./gradlew :app:hotRunJvm --mainClass com.example.MainKt |
--autoReload | Enable automatic reloading | ./gradlew :app:hotRunJvm --autoReload |
--auto | Enable automatic reloading (short form) | ./gradlew :app:hotRunJvm --auto |
--no-autoReload | Disable automatic reloading | ./gradlew :app:hotRunJvm --no-autoReload |
--no-auto | Disable 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:Reload Tasks (Explicit Mode Only)
When running in explicit mode, use reload tasks to apply your changes:Available Reload Tasks
reload: Reloads all currently running applications in the projecthotReload<Target><Compilation>: Reloads applications using a specific source set (e.g.,hotReloadJvmMain)
Async Run Tasks
For advanced use cases, async variants of the run tasks are available:Output Redirection
By default, async tasks write output to:- stdout:
build/run/<target>/hotRunJvm.stdout.txt - stderr:
build/run/<target>/hotRunJvm.stderr.txt
Examples
Basic Usage
Start your application with hot reload:Auto Reload Mode
Run with automatic reload on file changes:Custom Main Class
Run a specific main class:Background Execution
Launch in the background:Stopping the Application
When running in normal (blocking) mode:- Press
Ctrl+Cin the terminal to stop the application
- 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
- See Gradle Tasks Reference for all available tasks
- Learn how to configure tasks in your build script
- Check the API Reference for system properties you can use