build.gradle.kts
3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.spring) apply false
alias(libs.plugins.kotlin.jpa) apply false
alias(libs.plugins.spring.boot) apply false
alias(libs.plugins.spring.dependency.management) apply false
}
allprojects {
group = providers.gradleProperty("vibeerp.group").get()
version = providers.gradleProperty("vibeerp.version").get()
}
// Enforce the architecture-level dependency rules (CLAUDE.md guardrail #9):
//
// 1. PBCs may NEVER depend on other PBCs.
// Cross-PBC interaction goes through api.v1.ext.<pbc> service
// interfaces or the event bus.
//
// 2. PBCs may NEVER depend on `:platform:platform-bootstrap`.
// Bootstrap is the application entry point that ASSEMBLES PBCs;
// depending on it inverts the layering. PBCs depend on platform
// runtime modules (persistence, plugins, i18n, etc.) only.
//
// 3. Plug-ins (modules carrying the `vibeerp.module-kind=plugin` ext
// property) may ONLY depend on `:api:api-v1`. They never see
// `:platform:*` or `:pbc:*` internals.
//
// All three rules fail the build at configuration time.
//
// We use an explicit `extra["vibeerp.module-kind"]` marker rather than a
// pathname heuristic so that adding a plug-in under a different directory
// (e.g. `customer-plugins/foo/`) does not silently bypass the rule, and
// so that `:platform:platform-plugins` (which contains the substring
// "plugin-" in its path) is correctly classified as a runtime module, not
// a plug-in.
gradle.projectsEvaluated {
rootProject.allprojects.forEach { p ->
val ownPath: String = p.path
val moduleKind: String? = p.extra.properties["vibeerp.module-kind"] as String?
val checkedConfigs = listOf("api", "implementation", "compileOnly", "compileClasspath")
val projectDeps = p.configurations
.matching { it.name in checkedConfigs }
.flatMap { cfg ->
cfg.dependencies.filterIsInstance<org.gradle.api.artifacts.ProjectDependency>()
}
// Rule 1 & 2 — PBC dependency hygiene
if (ownPath.startsWith(":pbc:")) {
projectDeps.forEach { dep ->
@Suppress("DEPRECATION")
val depPath = dep.dependencyProject.path
if (depPath.startsWith(":pbc:") && depPath != ownPath) {
throw GradleException(
"Architectural violation in $ownPath: depends on $depPath. " +
"PBCs MUST NOT depend on other PBCs. Use api.v1 service " +
"interfaces (org.vibeerp.api.v1.ext.<pbc>) or the event bus."
)
}
if (depPath == ":platform:platform-bootstrap") {
throw GradleException(
"Architectural violation in $ownPath: depends on $depPath. " +
"PBCs MUST NOT depend on platform-bootstrap (the application " +
"entry point). Depend on platform runtime modules only."
)
}
}
}
// Rule 3 — Plug-in dependency hygiene (driven by an explicit marker)
if (moduleKind == "plugin") {
projectDeps.forEach { dep ->
@Suppress("DEPRECATION")
val depPath = dep.dependencyProject.path
if (depPath.startsWith(":platform:") || depPath.startsWith(":pbc:")) {
throw GradleException(
"Architectural violation in $ownPath: depends on internal module $depPath. " +
"Plug-ins may only depend on :api:api-v1."
)
}
}
}
}
}