or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

compilation-tasks.mddependency-management.mddsl-extensions.mdindex.mdjavascript-webassembly.mdmultiplatform-targets.mdplugin-configuration.md
tile.json

tessl/maven-org-jetbrains-kotlin--kotlin-gradle-plugin

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

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.jetbrains.kotlin/kotlin-gradle-plugin@2.2.x

To install, run

npx @tessl/cli install tessl/maven-org-jetbrains-kotlin--kotlin-gradle-plugin@2.2.0

index.mddocs/

Kotlin Gradle Plugin

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.

Package Information

  • Package Name: org.jetbrains.kotlin:kotlin-gradle-plugin
  • Package Type: Gradle Plugin (Maven)
  • Language: Kotlin
  • Installation: id("org.jetbrains.kotlin.jvm") version "2.2.0" (or other platform variants)

Core Plugin Applications

// JVM projects
plugins {
    id("org.jetbrains.kotlin.jvm") version "2.2.0"
}

// Multiplatform projects  
plugins {
    id("org.jetbrains.kotlin.multiplatform") version "2.2.0"
}

// Android projects
plugins {
    id("org.jetbrains.kotlin.android") version "2.2.0"
}

// JavaScript projects
plugins {
    id("org.jetbrains.kotlin.js") version "2.2.0"
}

Basic Usage

// JVM project with Kotlin DSL
plugins {
    id("org.jetbrains.kotlin.jvm") version "2.2.0"
}

kotlin {
    jvmTarget = "11"
    
    compilerOptions {
        freeCompilerArgs = listOf("-Xjsr305=strict")
    }
}

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-stdlib")
    testImplementation("org.jetbrains.kotlin:kotlin-test")
}
// Multiplatform project
plugins {
    id("org.jetbrains.kotlin.multiplatform") version "2.2.0"
}

kotlin {
    jvm()
    js(IR) {
        browser()
        nodejs()
    }
    
    sourceSets {
        commonMain {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
            }
        }
        jvmMain {
            dependencies {
                implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
            }
        }
    }
}

Architecture

The Kotlin Gradle Plugin provides a layered architecture:

  • Plugin Entry Points: Platform-specific wrapper plugins that configure appropriate targets and compilation tasks
  • DSL Extensions: Type-safe configuration DSL for Kotlin compilation options, targets, and source sets
  • Compilation Tasks: Gradle tasks that handle Kotlin compilation for different platforms (JVM, JS, Native)
  • Target Management: Multiplatform target configuration and binary generation
  • Dependency Resolution: Integration with Gradle's dependency management and automatic stdlib selection

Capabilities

Plugin Configuration and Setup

Core plugin application and project structure setup for different Kotlin project types.

// Plugin application patterns
id("org.jetbrains.kotlin.jvm") version "2.2.0"
id("org.jetbrains.kotlin.multiplatform") version "2.2.0"
id("org.jetbrains.kotlin.android") version "2.2.0"
id("org.jetbrains.kotlin.js") version "2.2.0"

Plugin Configuration

DSL Extensions and Project Configuration

Type-safe DSL for configuring Kotlin projects, compiler options, and build settings.

kotlin {
    jvmTarget: String
    compilerOptions: KotlinJvmCompilerOptions.() -> Unit
    sourceSets: NamedDomainObjectContainer<KotlinSourceSet>
}

DSL Extensions

Compilation Tasks and Build Process

Gradle tasks that handle Kotlin compilation, including incremental compilation and compiler options.

tasks.withType<KotlinCompile> {
    compilerOptions: KotlinJvmCompilerOptions
    destinationDirectory: DirectoryProperty
    classpath: ConfigurableFileCollection
}

Compilation Tasks

Multiplatform Target Configuration

Configuration and management of multiple platform targets in Kotlin Multiplatform projects.

kotlin {
    jvm(): KotlinJvmTarget
    js(compiler: KotlinJsCompilerType): KotlinJsTarget
    iosX64(): KotlinNativeTarget
    sourceSets: KotlinSourceSetContainer
}

Multiplatform Targets

Dependency Management and Publishing

Integration with Gradle's dependency resolution and Maven publishing for Kotlin artifacts.

dependencies {
    implementation(dependencyNotation: Any)
    api(dependencyNotation: Any)
    compileOnly(dependencyNotation: Any)
}

Dependency Management

JavaScript and WebAssembly Support

Specialized support for Kotlin/JS and Kotlin/Wasm compilation with Node.js and browser targets.

kotlin {
    js(IR) {
        browser(): KotlinJsBrowserDsl
        nodejs(): KotlinJsNodeDsl  
    }
    wasmJs(): KotlinWasmJsTarget
}

JavaScript and WebAssembly

Common Types

interface KotlinProjectExtension {
    val sourceSets: NamedDomainObjectContainer<KotlinSourceSet>
}

interface KotlinMultiplatformExtension : KotlinProjectExtension {
    fun jvm(name: String = "jvm", configure: KotlinJvmTarget.() -> Unit = {}): KotlinJvmTarget
    fun js(name: String = "js", configure: KotlinJsTarget.() -> Unit = {}): KotlinJsTarget
    fun android(configure: KotlinAndroidTarget.() -> Unit = {}): KotlinAndroidTarget
}

interface KotlinCompilerOptions<T : KotlinCommonCompilerOptions> {
    val languageVersion: Property<KotlinVersion>
    val apiVersion: Property<KotlinVersion>
    val freeCompilerArgs: ListProperty<String>
}

abstract class KotlinCompile : AbstractCompile(), KotlinCompilationTask<KotlinJvmCompilerOptions> {
    abstract override val compilerOptions: KotlinJvmCompilerOptions
}