Dylan Sale
10/26/2023, 8:18 AMDylan Sale
10/26/2023, 8:45 AM@Test
fun `architecture is enforced`() {
val modules = Konsist.scopeFromServices()
.files
.map { it.moduleName }
//There is a common subproject that they can import
.filter { !it.contains("/common/") }
.toSet()
Konsist
.scopeFromServices()
.assertArchitecture {
val layers = modules.map { module ->
val packageName =
module.replaceFirst(Regex(".*/"), "")
Layer(packageName, "com.example.services.$packageName..")
}
layers.forEach {
it.dependsOnNothing() //Nothing being the other layers defined here
}
}
}
This does require that all packages in each module match the module name, but I can enforce that with another test.
(scopeFromServices() is an extension function that just imports the scope from the path)igor.wojda
10/30/2023, 2:26 PM