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.
This commit is contained in:
Stefan Mogeritsch 2026-01-03 22:54:22 +01:00
parent 5a142a26b4
commit bd0cc49cf5
2 changed files with 1 additions and 53 deletions

View File

@ -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 ?: ""

View File

@ -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<String>()
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)
}
}
}