chore(build): enable consistent JVM 25 configuration for Java & Kotlin, update Kotlin compilation flags
- Unified JVM toolchain to target Java 25 across all subprojects. - Applied consistent Kotlin compilation settings with support for JVM 25 target and enhanced compiler arguments. - Added technical reference document for Kotlin 2.3.0 and Java 25 compatibility guidelines.
This commit is contained in:
parent
ead48cf9f5
commit
cb933c7cc2
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
# Tech-Stack Referenz: Kotlin 2.3.0 & Java 25 (KMP)
|
||||
|
||||
### 1. Kern-Spezifikationen
|
||||
|
||||
| Komponente | Version | Status |
|
||||
| --- | --- | --- |
|
||||
| **Kotlin** | `2.3.0` | Stabil (K2 Compiler standardmäßig aktiv) |
|
||||
| **Java (JDK)** | `25` | LTS (Long-Term Support) |
|
||||
| **Gradle** | `9.2+` | Erforderlich für JDK 25 Support |
|
||||
| **Android Plugin (AGP)** | `8.8.0+` | Empfohlen für Gradle 9.x Kompatibilität |
|
||||
|
||||
---
|
||||
|
||||
### 2. Gradle Konfiguration (`build.gradle.kts`)
|
||||
|
||||
Für ein **Kotlin Multiplatform (KMP)** Projekt ist die Java Toolchain-Konfiguration entscheidend, um sicherzustellen, dass der Kotlin-Compiler und die JVM-Targets Java 25 korrekt ansprechen.
|
||||
|
||||
```kotlin
|
||||
plugins {
|
||||
kotlin("multiplatform") version "2.3.0"
|
||||
id("com.android.library") version "8.8.0" // Falls Android Target genutzt wird
|
||||
}
|
||||
|
||||
kotlin {
|
||||
// Globale Toolchain-Definition für alle JVM/Android Targets
|
||||
jvmToolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(25))
|
||||
}
|
||||
|
||||
jvm {
|
||||
compilations.all {
|
||||
compilerOptions.configure {
|
||||
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_25)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Weitere Targets (Beispiel iOS)
|
||||
iosArm64()
|
||||
iosSimulatorArm64()
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 3. Gradle Wrapper Update
|
||||
|
||||
Damit das Projekt Java 25 erkennt, muss der Wrapper auf dem neuesten Stand sein:
|
||||
|
||||
**Terminal-Befehl:**
|
||||
|
||||
```bash
|
||||
./gradlew wrapper --gradle-version 9.2 --distribution-type all
|
||||
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 4. Wichtige Kompatibilitätshinweise für das Plugin
|
||||
|
||||
* **IDE-Version:** Stelle sicher, dass **IntelliJ IDEA 2025.3** (oder neuer) installiert ist, da erst diese Version die volle Unterstützung für JDK 25 Sprachfeatures und das Kotlin 2.3.0 Plugin bietet.
|
||||
* **K2 Compiler:** Kotlin 2.3.0 nutzt den K2-Compiler. Falls das Google AI Pro Plugin Code-Analysen durchführt, sollte es auf dem K2-Modus basieren.
|
||||
* **Bytecode:** Java 25 Bytecode wird nur generiert, wenn das `jvmTarget` explizit auf `25` gesetzt ist. Andernfalls verbleibt Kotlin standardmäßig bei einer niedrigeren Version (meist 1.8 oder 11), was die neuen JDK-Features einschränken könnte.
|
||||
|
||||
---
|
||||
|
||||
### 5. Bekannte Features in diesem Setup
|
||||
|
||||
* **Java 25 Features:** Unterstützung für die finalen Versionen von *Scoped Values* und *Structured Concurrency*.
|
||||
* **Kotlin 2.3.0 Features:** Nutzung von `explicit backing fields` und dem verbesserten `unused return value` Checker.
|
||||
|
|
@ -48,8 +48,22 @@ allprojects {
|
|||
}
|
||||
|
||||
subprojects {
|
||||
// Note: Individual modules handle Kotlin compiler configuration
|
||||
// a Root project doesn't apply Kotlin plugins, so we can't configure KotlinCompile tasks here
|
||||
// FINALE KORREKTUR: Konsistente JVM-Target-Konfiguration für Java und Kotlin
|
||||
// basierend auf der Tech-Stack-Referenz.
|
||||
plugins.withType<org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper> {
|
||||
extensions.configure<org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension> {
|
||||
jvmToolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(25))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
compilerOptions {
|
||||
jvmTarget.set(JvmTarget.JVM_25)
|
||||
freeCompilerArgs.add("-Xannotation-default-target=param-property")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
useJUnitPlatform {
|
||||
|
|
@ -70,19 +84,7 @@ subprojects {
|
|||
plugins.withId("java") {
|
||||
val javaExt = extensions.getByType<JavaPluginExtension>()
|
||||
// Ensure a full JDK toolchain with compiler is available (Gradle will auto-download if missing)
|
||||
javaExt.toolchain.languageVersion.set(JavaLanguageVersion.of(24))
|
||||
|
||||
// Set Kotlin Toolchain for projects using Kotlin
|
||||
plugins.withId("org.jetbrains.kotlin.jvm") {
|
||||
extensions.configure<org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension> {
|
||||
jvmToolchain(24)
|
||||
}
|
||||
}
|
||||
plugins.withId("org.jetbrains.kotlin.multiplatform") {
|
||||
extensions.configure<org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension> {
|
||||
jvmToolchain(24)
|
||||
}
|
||||
}
|
||||
javaExt.toolchain.languageVersion.set(JavaLanguageVersion.of(25))
|
||||
|
||||
tasks.register<Test>("perfTest") {
|
||||
description = "Runs tests tagged with 'perf'"
|
||||
|
|
@ -116,23 +118,6 @@ subprojects {
|
|||
environment("PUPPETEER_EXECUTABLE_PATH", "/usr/bin/chromium")
|
||||
}
|
||||
|
||||
// Suche diesen Block am Ende von subprojects und ersetze ihn:
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
compilerOptions {
|
||||
// Dein bestehender Argument-Eintrag
|
||||
freeCompilerArgs.add("-Xannotation-default-target=param-property")
|
||||
|
||||
// WICHTIG: Parameter-Namen für Spring Boot & Reflection erhalten
|
||||
javaParameters.set(true)
|
||||
|
||||
// OPTIONAL: Ermöglicht die Nutzung von Context Receivers (hilfreich in modernen Architekturen)
|
||||
freeCompilerArgs.add("-Xcontext-receivers")
|
||||
|
||||
// Explizite Setzung des JVM Targets auf 25 (überschreibt IDE-Fehleinstellungen)
|
||||
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_25)
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------
|
||||
// Detekt & Ktlint default setup
|
||||
// ------------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user