feat: füge Wasm/JS-Feature-Toggle hinzu, optimiere Gradle-Build-Zeit durch bedingte Task-Deaktivierung
Signed-off-by: StefanMoCoAt <stefan.mo.co@gmail.com>
This commit is contained in:
parent
0426d4ee9a
commit
cfc412878f
|
|
@ -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
|
||||
|
|
|
|||
42
docs/99_Journal/2026-04-16_Gradle-Performance-Fix.md
Normal file
42
docs/99_Journal/2026-04-16_Gradle-Performance-Fix.md
Normal file
|
|
@ -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.
|
||||
|
|
@ -9,9 +9,12 @@ plugins {
|
|||
alias(libs.plugins.kotlinSerialization)
|
||||
}
|
||||
|
||||
val isWasmEnabled = findProperty("enableWasm")?.toString()?.toBoolean() ?: false
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
if (isWasmEnabled) {
|
||||
js(IR) {
|
||||
binaries.library()
|
||||
browser {
|
||||
|
|
@ -29,8 +32,12 @@ kotlin {
|
|||
}
|
||||
binaries.executable()
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain.dependencies {}
|
||||
|
||||
if (isWasmEnabled) {
|
||||
wasmJsMain.dependencies {
|
||||
// Core-Module
|
||||
implementation(projects.frontend.core.domain)
|
||||
|
|
@ -68,4 +75,5 @@ kotlin {
|
|||
implementation(projects.frontend.core.domain)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user