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.00
# Compose Multiplatform Desktop JVM
1
2
Compose 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.
3
4
## Package Information
5
6
- **Package Name**: org.jetbrains.compose.desktop:desktop-jvm
7
- **Package Type**: Maven
8
- **Language**: Kotlin
9
- **Installation**: Apply the Compose Multiplatform Gradle plugin
10
11
## Core Imports
12
13
Gradle Plugin (Kotlin DSL):
14
15
```kotlin
16
plugins {
17
id("org.jetbrains.compose") version "1.8.2"
18
}
19
```
20
21
Gradle Plugin (Groovy DSL):
22
23
```groovy
24
plugins {
25
id 'org.jetbrains.compose' version '1.8.2'
26
}
27
```
28
29
## Basic Usage
30
31
```kotlin
32
// Apply the plugin
33
plugins {
34
id("org.jetbrains.compose")
35
kotlin("jvm")
36
}
37
38
// Configure desktop application
39
compose.desktop {
40
application {
41
mainClass = "MainKt"
42
43
nativeDistributions {
44
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
45
packageName = "MyApp"
46
packageVersion = "1.0.0"
47
}
48
}
49
}
50
51
// Add desktop dependencies
52
dependencies {
53
implementation(compose.desktop.currentOs)
54
implementation(compose.material3)
55
implementation(compose.ui)
56
}
57
```
58
59
## Architecture
60
61
The Compose Multiplatform Desktop ecosystem consists of several key components:
62
63
- **Gradle Plugin**: Core plugin providing configuration DSL and task orchestration
64
- **Desktop Extensions**: Configuration APIs for application packaging and distribution
65
- **Desktop Components**: UI components optimized for desktop platforms
66
- **Resource Management**: Tools for bundling and accessing application resources
67
- **Build Types**: Support for debug and release builds with ProGuard integration
68
69
## Capabilities
70
71
### Gradle Plugin Configuration
72
73
Core plugin functionality for setting up Compose Multiplatform projects.
74
75
```kotlin { .api }
76
class ComposePlugin : Plugin<Project>
77
78
abstract class ComposeExtension @Inject constructor(
79
objects: ObjectFactory,
80
project: Project
81
) : ExtensionAware {
82
val dependencies: ComposePlugin.Dependencies
83
}
84
```
85
86
[Gradle Plugin Configuration](./gradle-plugin.md)
87
88
### Desktop Application Configuration
89
90
Desktop-specific application configuration and distribution settings.
91
92
```kotlin { .api }
93
abstract class DesktopExtension @Inject constructor(
94
private val objectFactory: ObjectFactory
95
) : ExtensionAware {
96
val application: JvmApplication
97
val nativeApplication: NativeApplication
98
fun application(fn: Action<JvmApplication>)
99
fun nativeApplication(fn: Action<NativeApplication>)
100
}
101
```
102
103
[Desktop Application Configuration](./desktop-application.md)
104
105
### Desktop Components
106
107
Desktop-optimized UI components for enhanced desktop experiences.
108
109
```kotlin { .api }
110
// SplitPane component for resizable panels
111
@ExperimentalSplitPaneApi
112
@Composable
113
fun VerticalSplitPane(
114
modifier: Modifier = Modifier,
115
splitPaneState: SplitPaneState = rememberSplitPaneState(),
116
content: SplitPaneScope.() -> Unit
117
)
118
119
// AnimatedImage component for GIF and animated image support
120
@Composable
121
fun AnimatedImage(
122
animatedImageLoader: AnimatedImageLoader,
123
modifier: Modifier = Modifier,
124
contentDescription: String? = null
125
)
126
```
127
128
[Desktop Components](./desktop-components.md)
129
130
### UI Tooling and Preview
131
132
Development-time tools for UI preview and testing capabilities.
133
134
```kotlin { .api }
135
@Target(AnnotationTarget.FUNCTION)
136
@Retention(AnnotationRetention.BINARY)
137
annotation class Preview(
138
val name: String = "",
139
val group: String = "",
140
val apiLevel: Int = -1,
141
val widthDp: Int = -1,
142
val heightDp: Int = -1,
143
val locale: String = "",
144
val fontScale: Float = 1f,
145
val showSystemUi: Boolean = false,
146
val showBackground: Boolean = false,
147
val backgroundColor: Long = 0,
148
val uiMode: Int = 0,
149
val device: String = Devices.DEFAULT
150
)
151
```
152
153
[UI Tooling and Preview](./ui-tooling.md)
154
155
### Resource Management
156
157
Tools for managing and bundling application resources.
158
159
```kotlin { .api }
160
abstract class ResourcesExtension {
161
// Resource configuration options
162
}
163
164
// Resource generation tasks
165
class GenerateResourceAccessorsTask : DefaultTask()
166
class PrepareComposeResources : DefaultTask()
167
```
168
169
[Resource Management](./resource-management.md)
170
171
## Extension Functions
172
173
```kotlin { .api }
174
// Repository configuration
175
fun RepositoryHandler.jetbrainsCompose(): MavenArtifactRepository
176
177
// Dependency helpers
178
fun KotlinDependencyHandler.compose(groupWithArtifact: String): String
179
fun DependencyHandler.compose(groupWithArtifact: String): String
180
```
181
182
## Types
183
184
### TargetFormat
185
186
```kotlin { .api }
187
enum class TargetFormat(
188
internal val id: String,
189
internal val targetOS: OS
190
) {
191
AppImage, Deb, Rpm, Dmg, Pkg, Exe, Msi;
192
193
val isCompatibleWithCurrentOS: Boolean
194
val outputDirName: String
195
val fileExt: String
196
}
197
```
198
199
### Dependency Objects
200
201
```kotlin { .api }
202
object DesktopDependencies {
203
val components: DesktopComponentsDependencies
204
val common: String
205
val linux_x64: String
206
val linux_arm64: String
207
val windows_x64: String
208
val windows_arm64: String
209
val macos_x64: String
210
val macos_arm64: String
211
val currentOs: String
212
val uiTestJUnit4: String
213
}
214
215
object DesktopComponentsDependencies {
216
val splitPane: String
217
val animatedImage: String
218
}
219
220
object CommonComponentsDependencies {
221
val resources: String
222
val uiToolingPreview: String
223
}
224
```