ForbiddenDependencySpec
Builds one predicate rule inside a forbid { } block: "modules matching from must not depend on modules matching to".
aalekh {
forbid {
from(":core:domain")
toModuleType(ModuleType.ANDROID_LIBRARY)
because("the domain layer stays platform-agnostic")
severity(Severity.ERROR) // default ERROR
}
forbid {
from(":feature:**")
to(":feature:**")
because("features must not depend on each other")
}
}Content copied to clipboard
Each side is selected either by path glob (from / to) or by module type (fromModuleType / toModuleType). The spec serializes to a plain, configuration-cache-safe string; predicates are never captured as lambdas.
Functions
Link copied to clipboard
Restricts the rule to api dependencies only - an "API-leak" rule. The from module may still depend on to via implementation; it just may not re-export it onto its own consumers with api. Use it to stop a module widening its public surface, e.g. forbid { from(":core:public"); to(":core:internal"); apiOnly() }.
Link copied to clipboard
Selects depending modules by ModuleType.
Link copied to clipboard
Selects forbidden dependency targets by ModuleType.