From bd0cc49cf5a5ed0a8c8880e66adfb8e5438e890d Mon Sep 17 00:00:00 2001 From: StefanMoCoAt Date: Sat, 3 Jan 2026 22:54:22 +0100 Subject: [PATCH] chore(build): remove `FeatureIsolationTask` and simplify exception handling in build script - Deleted `FeatureIsolationTask` for build script simplification and maintainability. - Replaced `_` with `e` in `Throwable` catch blocks to improve readability. --- build.gradle.kts | 2 +- .../at/mocode/gradle/FeatureIsolationTask.kt | 52 ------------------- 2 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/at/mocode/gradle/FeatureIsolationTask.kt diff --git a/build.gradle.kts b/build.gradle.kts index d2e791fa..09e35b35 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -233,7 +233,7 @@ tasks.register("archGuardNoFeatureToFeatureDeps") { val proj = try { dep.javaClass.getMethod("getDependencyProject").invoke(dep) as Project - } catch (_: Throwable) { + } catch (e: Throwable) { null } val target = proj?.path ?: "" diff --git a/buildSrc/src/main/kotlin/at/mocode/gradle/FeatureIsolationTask.kt b/buildSrc/src/main/kotlin/at/mocode/gradle/FeatureIsolationTask.kt deleted file mode 100644 index 99853f52..00000000 --- a/buildSrc/src/main/kotlin/at/mocode/gradle/FeatureIsolationTask.kt +++ /dev/null @@ -1,52 +0,0 @@ -package at.mocode.gradle - -import org.gradle.api.DefaultTask -import org.gradle.api.GradleException -import org.gradle.api.Project -import org.gradle.api.artifacts.ProjectDependency -import org.gradle.api.tasks.TaskAction - -abstract class FeatureIsolationTask : DefaultTask() { - - @TaskAction - fun check() { - val featurePrefix = ":frontend:features:" - val violations = mutableListOf() - - project.rootProject.subprojects.forEach { p -> - if (p.path.startsWith(featurePrefix)) { - // Check all configurations except test-related ones - p.configurations - .matching { cfg -> - val n = cfg.name.lowercase() - !n.contains("test") && !n.contains("debug") // ignore test/debug configs - } - .forEach { cfg -> - cfg.dependencies.withType(ProjectDependency::class.java).forEach { dep -> - // Use reflection to avoid compile-time issues with dependencyProject property - val target = try { - val method = dep.javaClass.getMethod("getDependencyProject") - val proj = method.invoke(dep) as Project - proj.path - } catch (e: Exception) { - "" - } - if (target.startsWith(featurePrefix) && target != p.path) { - violations += "${p.path} -> $target (configuration: ${cfg.name})" - } - } - } - } - } - - if (violations.isNotEmpty()) { - val msg = buildString { - appendLine("Feature isolation violation(s) detected:") - violations.forEach { appendLine(" - $it") } - appendLine() - appendLine("Policy: frontend features must not depend on other features. Use navigation/shared domain in :frontend:core instead.") - } - throw GradleException(msg) - } - } -}