Evgeny Stroykov
07/02/2024, 2:55 PMio.something.source
and io.something.target
. And I was trying to define layers like the following:
val source = Layer("Source", "io.something.source..")
val target = Layer("Target", "io.something.target..")
But when I add any assertion on target
layer, I have the following error:
com.lemonappdev.konsist.core.exception.KoPreconditionFailedException: Layer Target doesn't contain any files.
at com.lemonappdev.konsist.core.verify.KoArchitectureAssertKt.validateAllLayersAreValid(KoArchitectureAssert.kt:113)
(but there are some files in the corresponding package)
I've checked out Konsist source code and found isBuildOrTargetPath function which filters out any files from scope if their path contains /target/
— due to to fact that this is how Maven build directory is called. So looks like there is no any workaround in my case and it is not possible to deal with files in target
package no matter how exactly I create Konsist scope, is it?PoisonedYouth
07/02/2024, 3:11 PMval mavenModuleBuildDirectoryRegex = Regex("$projectRootPath/.+/$mavenBuildDirectoryName/.*".toMacOsSeparator())
matching your package path? Have you debugged it?Evgeny Stroykov
07/02/2024, 3:13 PMPoisonedYouth
07/02/2024, 3:17 PMPoisonedYouth
07/02/2024, 6:07 PMPoisonedYouth
07/02/2024, 6:12 PMtarget
directory should also check that src
is not part of the path to exclude everything below.Evgeny Stroykov
07/02/2024, 6:42 PMTo fix this and still match the target directory of submodules you need to check the path starting from the module root instead the project rootNot sure if it helps. Both desirable and undesirable
target
directories are under the module root directory, aren't they?
root
- module
- - src
- - - target (to be included into scope)
- - target (to be excluded from scope)
Maybe the matching logic for theThis would help in my case. However, I am wondering if this is a good solution in the general case, given that name ofdirectory should also check thattarget
is not part of the path to exclude everything below.src
src
directory is just a convention and may be overridden in a particular Maven project. I don't have any other ideas, though.PoisonedYouth
07/02/2024, 6:46 PMsrc
directory does not feel as a good solution but I don't know how to fix this universally. As you showed above both target
directories are below the same module root and only differ that one is part of the application sources and the other is the output directory of the maven build.
But aren't the target
and build
directory also only conventions and can be changed?Evgeny Stroykov
07/02/2024, 6:49 PMEvgeny Stroykov
07/02/2024, 6:56 PMtarget
or build
only at the beginning of relative url — not anywhere in the middle.
But not sure it is easy to get the module root directory there.Evgeny Stroykov
07/02/2024, 6:59 PMtarget
or build
somewhere in their path.PoisonedYouth
07/02/2024, 7:00 PMPoisonedYouth
07/02/2024, 7:01 PM