Official Gradle plugin for the Kotlin programming language that provides comprehensive build support for Kotlin projects including compilation, multiplatform development, Android integration, and native development capabilities
npx @tessl/cli install tessl/maven-org-jetbrains-kotlin--kotlin-gradle-plugin@2.2.00
# Kotlin Gradle Plugin
1
2
The Kotlin Gradle Plugin is the official build system integration for the Kotlin programming language ecosystem, providing comprehensive compilation and project management capabilities for Kotlin projects across multiple platforms including JVM, Android, JavaScript, Native, and Multiplatform development.
3
4
## Package Information
5
6
- **Package Name**: org.jetbrains.kotlin:kotlin-gradle-plugin
7
- **Package Type**: Gradle Plugin (Maven)
8
- **Language**: Kotlin
9
- **Installation**: `id("org.jetbrains.kotlin.jvm") version "2.2.0"` (or other platform variants)
10
11
## Core Plugin Applications
12
13
```kotlin
14
// JVM projects
15
plugins {
16
id("org.jetbrains.kotlin.jvm") version "2.2.0"
17
}
18
19
// Multiplatform projects
20
plugins {
21
id("org.jetbrains.kotlin.multiplatform") version "2.2.0"
22
}
23
24
// Android projects
25
plugins {
26
id("org.jetbrains.kotlin.android") version "2.2.0"
27
}
28
29
// JavaScript projects
30
plugins {
31
id("org.jetbrains.kotlin.js") version "2.2.0"
32
}
33
```
34
35
## Basic Usage
36
37
```kotlin
38
// JVM project with Kotlin DSL
39
plugins {
40
id("org.jetbrains.kotlin.jvm") version "2.2.0"
41
}
42
43
kotlin {
44
jvmTarget = "11"
45
46
compilerOptions {
47
freeCompilerArgs = listOf("-Xjsr305=strict")
48
}
49
}
50
51
dependencies {
52
implementation("org.jetbrains.kotlin:kotlin-stdlib")
53
testImplementation("org.jetbrains.kotlin:kotlin-test")
54
}
55
```
56
57
```kotlin
58
// Multiplatform project
59
plugins {
60
id("org.jetbrains.kotlin.multiplatform") version "2.2.0"
61
}
62
63
kotlin {
64
jvm()
65
js(IR) {
66
browser()
67
nodejs()
68
}
69
70
sourceSets {
71
commonMain {
72
dependencies {
73
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
74
}
75
}
76
jvmMain {
77
dependencies {
78
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
79
}
80
}
81
}
82
}
83
```
84
85
## Architecture
86
87
The Kotlin Gradle Plugin provides a layered architecture:
88
89
- **Plugin Entry Points**: Platform-specific wrapper plugins that configure appropriate targets and compilation tasks
90
- **DSL Extensions**: Type-safe configuration DSL for Kotlin compilation options, targets, and source sets
91
- **Compilation Tasks**: Gradle tasks that handle Kotlin compilation for different platforms (JVM, JS, Native)
92
- **Target Management**: Multiplatform target configuration and binary generation
93
- **Dependency Resolution**: Integration with Gradle's dependency management and automatic stdlib selection
94
95
## Capabilities
96
97
### Plugin Configuration and Setup
98
99
Core plugin application and project structure setup for different Kotlin project types.
100
101
```kotlin { .api }
102
// Plugin application patterns
103
id("org.jetbrains.kotlin.jvm") version "2.2.0"
104
id("org.jetbrains.kotlin.multiplatform") version "2.2.0"
105
id("org.jetbrains.kotlin.android") version "2.2.0"
106
id("org.jetbrains.kotlin.js") version "2.2.0"
107
```
108
109
[Plugin Configuration](./plugin-configuration.md)
110
111
### DSL Extensions and Project Configuration
112
113
Type-safe DSL for configuring Kotlin projects, compiler options, and build settings.
114
115
```kotlin { .api }
116
kotlin {
117
jvmTarget: String
118
compilerOptions: KotlinJvmCompilerOptions.() -> Unit
119
sourceSets: NamedDomainObjectContainer<KotlinSourceSet>
120
}
121
```
122
123
[DSL Extensions](./dsl-extensions.md)
124
125
### Compilation Tasks and Build Process
126
127
Gradle tasks that handle Kotlin compilation, including incremental compilation and compiler options.
128
129
```kotlin { .api }
130
tasks.withType<KotlinCompile> {
131
compilerOptions: KotlinJvmCompilerOptions
132
destinationDirectory: DirectoryProperty
133
classpath: ConfigurableFileCollection
134
}
135
```
136
137
[Compilation Tasks](./compilation-tasks.md)
138
139
### Multiplatform Target Configuration
140
141
Configuration and management of multiple platform targets in Kotlin Multiplatform projects.
142
143
```kotlin { .api }
144
kotlin {
145
jvm(): KotlinJvmTarget
146
js(compiler: KotlinJsCompilerType): KotlinJsTarget
147
iosX64(): KotlinNativeTarget
148
sourceSets: KotlinSourceSetContainer
149
}
150
```
151
152
[Multiplatform Targets](./multiplatform-targets.md)
153
154
### Dependency Management and Publishing
155
156
Integration with Gradle's dependency resolution and Maven publishing for Kotlin artifacts.
157
158
```kotlin { .api }
159
dependencies {
160
implementation(dependencyNotation: Any)
161
api(dependencyNotation: Any)
162
compileOnly(dependencyNotation: Any)
163
}
164
```
165
166
[Dependency Management](./dependency-management.md)
167
168
### JavaScript and WebAssembly Support
169
170
Specialized support for Kotlin/JS and Kotlin/Wasm compilation with Node.js and browser targets.
171
172
```kotlin { .api }
173
kotlin {
174
js(IR) {
175
browser(): KotlinJsBrowserDsl
176
nodejs(): KotlinJsNodeDsl
177
}
178
wasmJs(): KotlinWasmJsTarget
179
}
180
```
181
182
[JavaScript and WebAssembly](./javascript-webassembly.md)
183
184
## Common Types
185
186
```kotlin { .api }
187
interface KotlinProjectExtension {
188
val sourceSets: NamedDomainObjectContainer<KotlinSourceSet>
189
}
190
191
interface KotlinMultiplatformExtension : KotlinProjectExtension {
192
fun jvm(name: String = "jvm", configure: KotlinJvmTarget.() -> Unit = {}): KotlinJvmTarget
193
fun js(name: String = "js", configure: KotlinJsTarget.() -> Unit = {}): KotlinJsTarget
194
fun android(configure: KotlinAndroidTarget.() -> Unit = {}): KotlinAndroidTarget
195
}
196
197
interface KotlinCompilerOptions<T : KotlinCommonCompilerOptions> {
198
val languageVersion: Property<KotlinVersion>
199
val apiVersion: Property<KotlinVersion>
200
val freeCompilerArgs: ListProperty<String>
201
}
202
203
abstract class KotlinCompile : AbstractCompile(), KotlinCompilationTask<KotlinJvmCompilerOptions> {
204
abstract override val compilerOptions: KotlinJvmCompilerOptions
205
}
206
```