Skip to main content

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 reload
  • hotRun - Run default target with hot reload
Custom task registration:
build.gradle.kts
tasks.register<ComposeHotRun>("runHot") {
    mainClass.set("my.app.MainKt")
}

Properties

mainClass
Property<String>
required
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
isAutoReloadEnabled
Property<Boolean>
default:"false"
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.
compilation
Property<KotlinCompilation<*>>
The Kotlin compilation this task is associated with.Automatically set by the plugin for generated tasks.

Command Line Options

--mainClass
string
Override the main class name.
./gradlew hotRunJvm --mainClass=com.example.MainKt
--autoReload
boolean
default:"false"
Enable automatic recompilation and reload.
./gradlew hotRunJvm --autoReload=true
--auto
boolean
default:"false"
Alias for --autoReload.
./gradlew hotRunJvm --auto=true

Dependencies

  • Depends on hotSnapshot[Target][Compilation] task
  • Depends on hotRun[Target][Compilation]Argfile task (internal)

Example

build.gradle.kts
tasks.register<ComposeHotRun>("runMyApp") {
    mainClass.set("com.example.MyAppKt")
    jvmArgs("-Xmx2g")
    args("--debug")
}
./gradlew runMyApp
./gradlew runMyApp --auto  # Enable auto-reload mode

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 background
  • hotRunAsync - Run default target in background

Properties

mainClass
Property<String>
required
The fully qualified name of the main class to execute.
javaBinary
RegularFileProperty
Path to the Java executable to use.Automatically configured to use the JetBrains Runtime from the run task’s javaLauncher.
stdoutFile
RegularFileProperty
File to redirect standard output to.Default: build/run/[target][compilation]/[taskName].stdout.txt
stderrFile
RegularFileProperty
File to redirect standard error to.Default: build/run/[target][compilation]/[taskName].stderr.txt
stdinFile
RegularFileProperty
File to use as standard input (optional).

Command Line Options

--mainClass
string
Override the main class name.
--stdout
string
Path to redirect stdout to.
./gradlew hotRunJvmAsync --stdout=/tmp/app.log
--stderr
string
Path to redirect stderr to.
./gradlew hotRunJvmAsync --stderr=/tmp/app.err
--autoReload
boolean
Enable automatic recompilation and reload.
--auto
boolean
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

./gradlew hotRunJvmAsync
./gradlew reload  # Reload the running app
./gradlew hotReloadJvmMain  # Alternative reload command

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

className
Property<String>
required
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
funName
Property<String>
required
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

--className
string
Provide the class name.
--funName
string
Provide the function name.

Example

./gradlew hotDevJvmDev --className=com.example.MyClass --funName=MyComposable

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 compilation
  • hotReloadDesktopMain - Reload Desktop main compilation

Properties

agentPort
Property<Int>
The orchestration port of the running application.Automatically determined from the PID file created by the run task.
pendingRequestFile
RegularFileProperty
File containing the pending reload request with changed class files.Created by the ComposeHotSnapshotTask.

Task Action

  1. Connects to the running application via orchestration client
  2. Reads pending changes from the snapshot task
  3. Sends reload request with changed class files
  4. 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

# Start the application
./gradlew hotRunJvmAsync

# Make code changes, then reload
./gradlew hotReloadJvmMain

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:
./gradlew reload

Behavior

  • Depends on all ComposeHotReloadTask instances 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:
  • hotSnapshotJvmMain
  • hotSnapshotDesktopMain
Automatically run as a dependency of run and reload tasks.

Properties

classpath
ConfigurableFileCollection
The compilation classpath to snapshot.Path Sensitivity: RELATIVEIncremental: Yes
classpathSnapshotFile
RegularFileProperty
Output file containing the classpath snapshot.Location: build/run/[target][compilation]/classpath/.snapshot
pendingRequestFile
RegularFileProperty
Output file containing the pending reload request.Location: build/run/[target][compilation]/classpath/.request
classesDirectory
DirectoryProperty
Directory 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/hot

Task Action

Non-incremental run:
  • Takes a fresh classpath snapshot
  • Clears any pending reload requests
Incremental run:
  • 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 .class files
  • 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:
  • hotRunJvmArgfile
  • hotRunDesktopArgfile

Properties

jvmArguments
ListProperty<Any>
JVM arguments to include in the arg file.
arguments
ListProperty<Any>
Application arguments to include.
classpath
FileCollection
Classpath to include.
argFile
RegularFileProperty
Output argument file.

Custom Task Naming

The plugin generates task names using a camelCase pattern:

Run Tasks

hot + Run + [TargetName] + [CompilationName if not "main"]
Examples:
  • hotRunJvm (JVM target, main compilation)
  • hotRunDesktopTest (Desktop target, test compilation)

Reload Tasks

hot + Reload + [TargetName] + [CompilationName]
Examples:
  • hotReloadJvmMain
  • hotReloadDesktopMain

Snapshot Tasks

hot + Snapshot + [TargetName] + [CompilationName]
Examples:
  • hotSnapshotJvmMain
  • hotSnapshotDesktopMain

Dev Tasks

hot + Dev + [TargetName] + [CompilationName if not "dev"]
Examples:
  • hotDevJvmDev
  • hotDevDesktopDev

Build docs developers (and LLMs) love