Run Tasks
ComposeHotRun
Runs a Compose application with hot reload enabled. Package:org.jetbrains.compose.reload.gradle
Extends: JavaExec, AbstractComposeHotRun
Task Type: Untracked (always runs)
Usage
Generated tasks:hotRunJvm- Run JVM target with hot reloadhotRun- Run default target with hot reload
build.gradle.kts
Properties
The fully qualified name of the main class to execute.Can be provided via:
- Task configuration:
mainClass.set("com.example.MainKt") - Command line:
./gradlew hotRun --mainClass=com.example.MainKt - Gradle property:
-PmainClass=com.example.MainKt
Enables automatic recompilation and reload when source files change.When enabled, the plugin launches a separate Gradle daemon to continuously monitor and recompile changed files.Recommended: Use explicit reload mode (default) for better control.
The Kotlin compilation this task is associated with.Automatically set by the plugin for generated tasks.
Command Line Options
Override the main class name.
Enable automatic recompilation and reload.
Alias for
--autoReload.Dependencies
- Depends on
hotSnapshot[Target][Compilation]task - Depends on
hotRun[Target][Compilation]Argfiletask (internal)
Example
build.gradle.kts
ComposeHotAsyncRun
Runs a Compose application with hot reload in a detached background process. Package:org.jetbrains.compose.reload.gradle
Task Type: Untracked (always runs)
Usage
Generated tasks:hotRunJvmAsync- Run JVM target in backgroundhotRunAsync- Run default target in background
Properties
The fully qualified name of the main class to execute.
Path to the Java executable to use.Automatically configured to use the JetBrains Runtime from the run task’s
javaLauncher.File to redirect standard output to.Default:
build/run/[target][compilation]/[taskName].stdout.txtFile to redirect standard error to.Default:
build/run/[target][compilation]/[taskName].stderr.txtFile to use as standard input (optional).
Command Line Options
Override the main class name.
Path to redirect stdout to.
Path to redirect stderr to.
Enable automatic recompilation and reload.
Alias for
--autoReload.Behavior
- Launches the application as a detached process
- Kills any previously running instance automatically
- Creates a PID file to track the running process
- Output is redirected to files instead of console
Example
ComposeHotDevRun
Internal task for running dev compilations with a dev application wrapper. Package:org.jetbrains.compose.reload.gradle
Extends: AbstractComposeHotRun
Usage
Generated tasks:hotDevJvmDev- Run JVM dev compilation
Properties
The fully qualified class name containing the composable function.Can be provided via:
- System property:
-DclassName=com.example.MyClass - Gradle property:
-PclassName=com.example.MyClass - Command line:
--className=com.example.MyClass
The name of the composable function to execute.Can be provided via:
- System property:
-DfunName=MyComposable - Gradle property:
-PfunName=MyComposable - Command line:
--funName=MyComposable
Command Line Options
Provide the class name.
Provide the function name.
Example
Reload Tasks
ComposeHotReloadTask
Reloads changed classes into a running application. Package:org.jetbrains.compose.reload.gradle
Extends: DefaultTask
Caching: Disabled (should always run)
Usage
Generated tasks:hotReloadJvmMain- Reload JVM main compilationhotReloadDesktopMain- Reload Desktop main compilation
Properties
The orchestration port of the running application.Automatically determined from the PID file created by the run task.
File containing the pending reload request with changed class files.Created by the
ComposeHotSnapshotTask.Task Action
- Connects to the running application via orchestration client
- Reads pending changes from the snapshot task
- Sends reload request with changed class files
- Reports reload statistics (modifications, additions, deletions)
Dependencies
- Depends on
hotSnapshot[Target][Compilation]task
Condition
Only runs when a running application is detected (agentPort is present).Example
ComposeHotReloadLifecycleTask
Lifecycle task that reloads all running applications. Package:org.jetbrains.compose.reload.gradle
Task Name: reload
Extends: DefaultTask
Usage
This is the recommended task for triggering hot reload:Behavior
- Depends on all
ComposeHotReloadTaskinstances that have a running application - Provides a single command to reload all active hot reload sessions
Snapshot Tasks
ComposeHotSnapshotTask
Takes a snapshot of the compilation classpath to detect changed classes. Package:org.jetbrains.compose.reload.gradle
Extends: DefaultTask
Caching: Disabled (should always run)
Usage
Generated tasks:hotSnapshotJvmMainhotSnapshotDesktopMain
Properties
The compilation classpath to snapshot.Path Sensitivity: RELATIVEIncremental: Yes
Output file containing the classpath snapshot.Location:
build/run/[target][compilation]/classpath/.snapshotOutput file containing the pending reload request.Location:
build/run/[target][compilation]/classpath/.requestDirectory containing hot-reloaded class files.This directory is added to the runtime classpath so the running application can load changed classes.Location:
build/run/[target][compilation]/classpath/hotTask Action
Non-incremental run:- Takes a fresh classpath snapshot
- Clears any pending reload requests
- Compares current classpath with previous snapshot
- Detects added, modified, and removed class files
- Extracts changed classes from JARs
- Copies changed classes to
classesDirectory - Creates a reload request with all changes
Change Detection
The task detects changes in:- Individual
.classfiles - Classes within JAR files (using CRC checksums)
Utility Tasks
ComposeHotArgFileTask
Internal task that creates an argument file for the run task. Package:org.jetbrains.compose.reload.gradle
Generated Task Names:
hotRunJvmArgfilehotRunDesktopArgfile
Properties
JVM arguments to include in the arg file.
Application arguments to include.
Classpath to include.
Output argument file.
Custom Task Naming
The plugin generates task names using a camelCase pattern:Run Tasks
hotRunJvm(JVM target, main compilation)hotRunDesktopTest(Desktop target, test compilation)
Reload Tasks
hotReloadJvmMainhotReloadDesktopMain
Snapshot Tasks
hotSnapshotJvmMainhotSnapshotDesktopMain
Dev Tasks
hotDevJvmDevhotDevDesktopDev