KatachiFileConstraintDirectOnlyWithoutDirectoryException

A constraint asked for scope = FileConstraintRange.DirectOnly somewhere that has no directory of its own.

"Directly in" needs one directory to be directly in. A role lives wherever its layout { } blocks put it, and directly under layout { } or inside ":".module { } the block writes into the project root, which every other block of that layout { } shares. Ignoring the flag there would leave a constraint that checks something other than what it says.

Written on a role, this is thrown while architecture { } is evaluated. Written inside a layout { }, it is thrown when the layout is evaluated, because layout { } is deferred.

Example 1: catch a direct-only constraint written on the role itself

shouldThrow<KatachiFileConstraintDirectOnlyWithoutDirectoryException> {
architecture {
"util".group {
"Util" {
fileConstraint("uses the stdlib only", scope = FileConstraintRange.DirectOnly) { emptyList() }
layout { "util" { "*.kt".file() } }
}
}
}
}.declaredAt.fileName shouldBe "ProjectArchitecture.kt"

Properties

Link copied to clipboard
open val cause: Throwable?
Link copied to clipboard

Where the constraint was written.

Link copied to clipboard
open val message: String?
Link copied to clipboard
val name: String?

What the constraint was called, or null when it was declared without a name.