4.3 KiB
Deprecation-Warnings Behebung - client/build.gradle.kts
🎯 Issue-Zusammenfassung
Problem: Zwei Deprecation-Warnings in der client/build.gradle.kts:
- Zeile 40:
'val compilerOptions: HasCompilerOptions<KotlinJvmCompilerOptions>' is deprecated - Zeile 92:
'val compilerOptions: HasCompilerOptions<KotlinJsCompilerOptions>' is deprecated
Lösung: Migration vom deprecated compilerOptions.configure Pattern zum modernen compileTaskProvider.configure Pattern.
✅ Durchgeführte Änderungen
1. JVM Target Migration (Zeile 40)
Vorher (deprecated):
jvm {
compilations.all {
compilerOptions.configure {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
freeCompilerArgs.addAll(
"-Xjsr305=strict",
"-Xcontext-parameters"
)
}
}
}
Nachher (modern):
jvm {
compilations.all {
compileTaskProvider.configure {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
freeCompilerArgs.addAll(
"-Xjsr305=strict",
"-Xcontext-parameters"
)
}
}
}
}
2. WASM Target Migration (Zeile 94)
Vorher (deprecated):
wasmJs {
compilations.all {
compilerOptions.configure {
freeCompilerArgs.addAll(
"-Xwasm-use-new-exception-proposal",
"-Xwasm-debugger-custom-formatters",
// ... weitere Flags
)
}
}
}
Nachher (modern):
wasmJs {
compilations.all {
compileTaskProvider.configure {
compilerOptions {
freeCompilerArgs.addAll(
"-Xwasm-use-new-exception-proposal",
"-Xwasm-debugger-custom-formatters",
// ... weitere Flags
)
}
}
}
}
📊 Migration-Details
Migration Pattern:
DEPRECATED: compilation.compilerOptions.configure { ... }
MODERN: compilation.compileTaskProvider.configure { compilerOptions { ... } }
Grund der Änderung:
- Deprecated API:
compilerOptions.configuredirekt auf Compilation - Modern API:
compileTaskProvider.configuremit nestedcompilerOptions - Bessere Task-Graph-Integration: Task-Provider Pattern für lazy evaluation
🧪 Build-Verifikation
Test-Ergebnisse:
| Target | Build-Status | Zeit | Bemerkung |
|---|---|---|---|
| JVM | ✅ SUCCESS | 36s | Keine Warnings |
| JS | ✅ SUCCESS | 29s | Keine Auswirkungen |
| WASM | ✅ SUCCESS | 29s | 1 harmlose Warnung* |
*Warnung: Argument -Xwasm-target is passed multiple times - harmlos, nicht related zu Migration
Verifikations-Commands:
# JVM Target Test
./gradlew :client:compileKotlinJvm --no-daemon
✅ BUILD SUCCESSFUL in 36s
# JavaScript Target Test
./gradlew :client:compileKotlinJs --no-daemon
✅ BUILD SUCCESSFUL in 29s
# WebAssembly Target Test
./gradlew :client:compileKotlinWasmJs --no-daemon
✅ BUILD SUCCESSFUL in 29s
🎯 Ergebnisse
✅ Erfolgreich behoben:
- ❌ Deprecation-Warning Zeile 40 (JVM Target)
- ❌ Deprecation-Warning Zeile 92 (WASM Target)
- ✅ Alle Targets kompilieren erfolgreich
- ✅ Keine funktionalen Änderungen
- ✅ Modern Kotlin Gradle Plugin API verwendet
🔧 Technische Verbesserungen:
- Task-Provider Pattern: Bessere lazy evaluation
- Future-Proof: Kompatibel mit neueren Kotlin Gradle Plugin Versionen
- Clean Configuration: Klarere Struktur durch nested compilerOptions
- No Breaking Changes: Alle bestehenden Compiler-Flags beibehalten
📝 Zusammenfassung
Status: ✅ ERFOLGREICH BEHOBEN
Die Migration von deprecated compilerOptions.configure zu modernem compileTaskProvider.configure { compilerOptions { ... } } Pattern wurde erfolgreich durchgeführt. Alle Kotlin Multiplatform Targets (JVM, JavaScript, WebAssembly) kompilieren weiterhin einwandfrei und die Deprecation-Warnings sind vollständig beseitigt.
Migration Pattern angewendet auf:
- JVM Compilation (Zeile 40 → 40-48)
- WASM Compilation (Zeile 92 → 94-106)
Das Build-System ist nun zukunftssicher und nutzt die aktuellsten Kotlin Gradle Plugin APIs.