diff --git a/build.gradle.kts b/build.gradle.kts index 9899ab9e..ba4fdb46 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -38,6 +38,8 @@ plugins { // ### ALLPROJECTS CONFIGURATION ### // ################################################################## +val isWasmEnabled = findProperty("enableWasm")?.toString()?.toBoolean() ?: false + // --------------------------------------------------------------- // Zentrale Versionierung — liest version.properties (SemVer) // --------------------------------------------------------------- @@ -92,7 +94,7 @@ subprojects { minHeapSize = "512m" maxHeapSize = "2g" // Parallel test execution for better performance - maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 4).coerceAtLeast(1) } // --------------------------------------------------------------------------- @@ -111,7 +113,28 @@ subprojects { // (A) Source map configuration is handled via `gradle.properties` (global Kotlin/JS settings) // to avoid compiler-flag incompatibilities across toolchains. - // (B) JS test executable compilation/sync is currently very noisy (duplicate resource copying from jsMain + jsTest). + // (B) Conditional Wasm/JS Target handling based on `enableWasm` property + // This significantly reduces build times during Desktop development. + // Flag is defined at the beginning of the script. + + // If Wasm is disabled, we skip the intensive JS/WASM compilation tasks + // for modules that are not strictly JVM-only. + if (!isWasmEnabled) { + tasks.matching { + val n = it.name + n.contains("wasmJs", ignoreCase = true) || + n.contains("KotlinJs", ignoreCase = true) || + n.contains("JsIr", ignoreCase = true) || + n.contains("packageJsUpper", ignoreCase = true) || + n.contains("jsProcessResources", ignoreCase = true) || + n.contains("wasmJsProcessResources", ignoreCase = true) + }.configureEach { + enabled = false + group = "disabled" + } + } + + // (C) JS test executable compilation/sync is currently very noisy (duplicate resource copying from jsMain + jsTest). // We disable JS/WASM JS test executables in CI/build to keep output warning-free. tasks.matching { val n = it.name diff --git a/docs/99_Journal/2026-04-16_Gradle-Performance-Fix.md b/docs/99_Journal/2026-04-16_Gradle-Performance-Fix.md new file mode 100644 index 00000000..1101c245 --- /dev/null +++ b/docs/99_Journal/2026-04-16_Gradle-Performance-Fix.md @@ -0,0 +1,42 @@ +# 📓 Journal-Eintrag: 2026-04-16 - Gradle Build-Performance Optimierung + +## 🏗️ Status Quo + +Die Build-Zeiten stiegen nach der Integration von `wasmJs` auf bis zu 32 Minuten an. Dies lag primär daran, dass für +fast alle Module (Backend-Domains, Core, Frontend) bei jedem Build auch die JS- und WASM-Targets kompiliert wurden, +obwohl diese für die Desktop-Entwicklung nicht benötigt werden. + +## 🚀 Optimierungen + +### 1. Wasm/JS Feature Toggle (`enableWasm`) + +- **Neues Flag**: In der `gradle.properties` wurde das Flag `enableWasm=false` eingeführt. +- **Root build.gradle.kts**: Wenn `enableWasm=false` ist, werden alle Tasks, die `wasmJs`, `KotlinJs` oder `JsIr` im + Namen tragen, global deaktiviert. +- **Web-Shell Optimierung**: Das Modul `:frontend:shells:meldestelle-web` wurde so angepasst, dass die Targets `js` und + `wasmJs` sowie deren Abhängigkeiten nur dann konfiguriert werden, wenn das Flag aktiv ist. + +### 2. Ressourcen-Management & Stabilität + +- **Memory Settings**: Die JVM-Argumente für den Gradle-Daemon und den Kotlin-Daemon wurden auf 8GB (`-Xmx8g`) + vereinheitlicht, um OOM-Fehler bei intensiven JS-Kompilierungen zu vermeiden. +- **Parallelisierung**: `maxParallelForks` für Tests wurde auf `CPU/4` reduziert, um dem Gradle-Daemon in + Ressourcen-kritischen Phasen mehr Spielraum zu geben und Swapping zu verhindern. +- **Worker-Limits**: `org.gradle.workers.max=8` sorgt für eine kontrollierte Auslastung der CPU-Kerne. + +### 3. Build-Hygiene + +- Zusätzliche Deaktivierung von redundanten Resource-Processing Tasks (`jsProcessResources`, `wasmJsProcessResources`), + wenn Wasm deaktiviert ist. +- Unterdrückung von Node.js Deprecation Warnings in allen Exec-Tasks. + +## 📈 Erwartetes Resultat + +- **Desktop-Entwicklung**: Reduzierung der Build-Zeit um ca. 60-80%, da die kompletten JS/WASM Compiler-Pipelines + übersprungen werden. +- **Web-Entwicklung**: Stabilere Builds durch erhöhte Heap-Limits und kontrollierte Parallelisierung. + +--- +**🏗️ [Lead Architect]**: Gradle-Infrastruktur auf modulares Target-Handling umgestellt. +**🐧 [DevOps Engineer]**: Ressourcen-Limits für lokale Entwicklung und CI harmonisiert. +**🧹 [Curator]**: Build-Performance Strategie dokumentiert. diff --git a/frontend/shells/meldestelle-web/build.gradle.kts b/frontend/shells/meldestelle-web/build.gradle.kts index beb2bed3..ed3d9a63 100644 --- a/frontend/shells/meldestelle-web/build.gradle.kts +++ b/frontend/shells/meldestelle-web/build.gradle.kts @@ -9,63 +9,71 @@ plugins { alias(libs.plugins.kotlinSerialization) } +val isWasmEnabled = findProperty("enableWasm")?.toString()?.toBoolean() ?: false + kotlin { jvm() - js(IR) { - binaries.library() - browser { - testTask { - enabled = false + if (isWasmEnabled) { + js(IR) { + binaries.library() + browser { + testTask { + enabled = false + } } } - } - wasmJs { - browser { - testTask { - enabled = false + wasmJs { + browser { + testTask { + enabled = false + } } + binaries.executable() } - binaries.executable() } sourceSets { - wasmJsMain.dependencies { - // Core-Module - implementation(projects.frontend.core.domain) - implementation(projects.frontend.core.designSystem) - implementation(projects.frontend.core.navigation) - implementation(projects.frontend.core.network) - implementation(projects.frontend.core.auth) + commonMain.dependencies {} - // Feature-Module (die öffentlich sein dürfen) - implementation(projects.frontend.features.veranstaltungFeature) - implementation(projects.frontend.features.turnierFeature) - implementation(projects.frontend.features.nennungFeature) - implementation(projects.frontend.features.billingFeature) + if (isWasmEnabled) { + wasmJsMain.dependencies { + // Core-Module + implementation(projects.frontend.core.domain) + implementation(projects.frontend.core.designSystem) + implementation(projects.frontend.core.navigation) + implementation(projects.frontend.core.network) + implementation(projects.frontend.core.auth) - // Compose Multiplatform - implementation(compose.runtime) - implementation(compose.foundation) - implementation(compose.material3) - implementation(compose.ui) - implementation(compose.components.resources) - implementation(libs.compose.materialIconsExtended) + // Feature-Module (die öffentlich sein dürfen) + implementation(projects.frontend.features.veranstaltungFeature) + implementation(projects.frontend.features.turnierFeature) + implementation(projects.frontend.features.nennungFeature) + implementation(projects.frontend.features.billingFeature) - // DI (Koin) - implementation(libs.koin.core) - implementation(libs.koin.compose) - implementation(libs.koin.compose.viewmodel) + // Compose Multiplatform + implementation(compose.runtime) + implementation(compose.foundation) + implementation(compose.material3) + implementation(compose.ui) + implementation(compose.components.resources) + implementation(libs.compose.materialIconsExtended) - // Bundles - implementation(libs.bundles.kmp.common) - implementation(libs.bundles.compose.common) - } + // DI (Koin) + implementation(libs.koin.core) + implementation(libs.koin.compose) + implementation(libs.koin.compose.viewmodel) - wasmJsTest.dependencies { - // Core-Module - implementation(projects.frontend.core.domain) + // Bundles + implementation(libs.bundles.kmp.common) + implementation(libs.bundles.compose.common) + } + + wasmJsTest.dependencies { + // Core-Module + implementation(projects.frontend.core.domain) + } } } } diff --git a/gradle.properties b/gradle.properties index 4e54418f..3b180d2e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -68,6 +68,11 @@ org.gradle.java.installations.auto-detect=true dev.port.offset=0 # Set dev.port.offset=100 for second developer # Set dev.port.offset=200 for the third developer +# ------------------------------------------------------------------ +# Wasm/JS Feature Toggle +# ------------------------------------------------------------------ +# Setze enableWasm=true, um die Web-App zu bauen oder Web-spezifische +# Module zu testen. Default=false spart massiv Zeit beim Desktop-Build. enableWasm=false # Dokka Gradle plugin V2 mode (with helpers for V1 compatibility)