Compose Multiplatform Desktop JVM support library for building cross-platform desktop applications with declarative UI framework based on Jetpack Compose
npx @tessl/cli install tessl/maven-org-jetbrains-compose-desktop--desktop-jvm@1.8.0Compose Multiplatform Desktop JVM provides comprehensive tooling and components for building cross-platform desktop applications using Jetpack Compose on the JVM. This package includes Gradle plugins for application configuration, desktop-specific UI components, resource management, and distribution tools for Windows, macOS, and Linux.
Gradle Plugin (Kotlin DSL):
plugins {
id("org.jetbrains.compose") version "1.8.2"
}Gradle Plugin (Groovy DSL):
plugins {
id 'org.jetbrains.compose' version '1.8.2'
}// Apply the plugin
plugins {
id("org.jetbrains.compose")
kotlin("jvm")
}
// Configure desktop application
compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "MyApp"
packageVersion = "1.0.0"
}
}
}
// Add desktop dependencies
dependencies {
implementation(compose.desktop.currentOs)
implementation(compose.material3)
implementation(compose.ui)
}The Compose Multiplatform Desktop ecosystem consists of several key components:
Core plugin functionality for setting up Compose Multiplatform projects.
class ComposePlugin : Plugin<Project>
abstract class ComposeExtension @Inject constructor(
objects: ObjectFactory,
project: Project
) : ExtensionAware {
val dependencies: ComposePlugin.Dependencies
}Desktop-specific application configuration and distribution settings.
abstract class DesktopExtension @Inject constructor(
private val objectFactory: ObjectFactory
) : ExtensionAware {
val application: JvmApplication
val nativeApplication: NativeApplication
fun application(fn: Action<JvmApplication>)
fun nativeApplication(fn: Action<NativeApplication>)
}Desktop Application Configuration
Desktop-optimized UI components for enhanced desktop experiences.
// SplitPane component for resizable panels
@ExperimentalSplitPaneApi
@Composable
fun VerticalSplitPane(
modifier: Modifier = Modifier,
splitPaneState: SplitPaneState = rememberSplitPaneState(),
content: SplitPaneScope.() -> Unit
)
// AnimatedImage component for GIF and animated image support
@Composable
fun AnimatedImage(
animatedImageLoader: AnimatedImageLoader,
modifier: Modifier = Modifier,
contentDescription: String? = null
)Development-time tools for UI preview and testing capabilities.
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.BINARY)
annotation class Preview(
val name: String = "",
val group: String = "",
val apiLevel: Int = -1,
val widthDp: Int = -1,
val heightDp: Int = -1,
val locale: String = "",
val fontScale: Float = 1f,
val showSystemUi: Boolean = false,
val showBackground: Boolean = false,
val backgroundColor: Long = 0,
val uiMode: Int = 0,
val device: String = Devices.DEFAULT
)Tools for managing and bundling application resources.
abstract class ResourcesExtension {
// Resource configuration options
}
// Resource generation tasks
class GenerateResourceAccessorsTask : DefaultTask()
class PrepareComposeResources : DefaultTask()// Repository configuration
fun RepositoryHandler.jetbrainsCompose(): MavenArtifactRepository
// Dependency helpers
fun KotlinDependencyHandler.compose(groupWithArtifact: String): String
fun DependencyHandler.compose(groupWithArtifact: String): Stringenum class TargetFormat(
internal val id: String,
internal val targetOS: OS
) {
AppImage, Deb, Rpm, Dmg, Pkg, Exe, Msi;
val isCompatibleWithCurrentOS: Boolean
val outputDirName: String
val fileExt: String
}object DesktopDependencies {
val components: DesktopComponentsDependencies
val common: String
val linux_x64: String
val linux_arm64: String
val windows_x64: String
val windows_arm64: String
val macos_x64: String
val macos_arm64: String
val currentOs: String
val uiTestJUnit4: String
}
object DesktopComponentsDependencies {
val splitPane: String
val animatedImage: String
}
object CommonComponentsDependencies {
val resources: String
val uiToolingPreview: String
}