LayerConfig

abstract class LayerConfig @Inject constructor(val name: String, val declarationOrder: Int, objects: ObjectFactory)(source)

Configures a single architectural layer inside the layers { } block.

aalekh {
layers {
layer("domain") {
modules(":core:domain", ":feature:*:domain")
}
layer("data") {
modules(":core:data", ":feature:*:data")
canOnlyDependOn("domain")
}
layer("presentation") {
modules(":feature:*:ui", ":app")
canOnlyDependOn("domain", "data")
}
}
}

Module patterns support a single * wildcard matching one path segment, and ** matching any number of segments.

Parameters

name

The layer name, unique within the block.

declarationOrder

Zero-based position of this layer in the layers { } block. Gradle's named container iterates alphabetically, which would make an overlapping-pattern resolution - and the order the report draws the swimlanes in - depend on layer spelling rather than on how the architecture was written down. Aalekh sorts by this instead, so domain, data, presentation stays in that order everywhere.

Constructors

Link copied to clipboard
@Inject
constructor(name: String, declarationOrder: Int, objects: ObjectFactory)

Properties

Link copied to clipboard
val allowedDependencyLayers: ListProperty<String>

Layer names this layer is permitted to depend on. Empty means no restriction.

Link copied to clipboard
Link copied to clipboard
val hasRestriction: Property<Boolean>

Whether allowedDependencyLayers is an allowlist (true) or unrestricted (false).

Link copied to clipboard
val modulePatterns: ListProperty<String>

Glob patterns identifying which modules belong to this layer.

Link copied to clipboard

Functions

Link copied to clipboard
fun canOnlyDependOn(vararg layerNames: String)

Restricts this layer to only depend on the named layers. Any dependency on a module outside these layers is a violation.

Link copied to clipboard
fun modules(vararg patterns: String)

Declares which modules belong to this layer. Supports * and ** glob patterns.