Open thomascaillier opened 1 year ago
That's an interesting case. Am I right in assuming that you do not consider a.b
a submodule of a
? If so, why is a
even a module in the first place?
We currently do not really support nested modules(, yet), and your suggested solution would establish an arrangement, in which nested modules are automatically exposed to other modules. While apparently that's what you expect in this case, but I wonder how common the same source code arrangement is and the nesting is supposed to be used to control that a.c
only uses particular types of a.b
but still hide both of them from d
?
Use case
In order to expose the types of a module and all of its sub packages, I'm implementing my own
ApplicationModuleDetectionStrategy
as described in the documentation, as well i can have module base packages as following :Expected behaviour
org.myapp.a.b
is a module, soorg.myapp.d
can depend onorg.myapp.a.b.SomeService
What's happening
My modularity test based on
ApplicationModules.of(org.myapp.MyApplication.class).verify()
fails because moduleorg.myapp.d
depends on non-exposed typeorg.myapp.a.b.SomeService
In-depth analysis
Diving in how the
ApplicationModules:detectViolations
method works, I found thatApplicationModules:getModulesByType
was the origin of my problem:In my case, multiples modules contains my type
org.myapp.a.b.SomeService
(org.myapp.a
andorg.myapp.a.b
), but only the first one is taken. Then, becauseorg.myapp.a.b.SomeService
isn't exposed by the first moduleorg.myapp.a
, a violation is detected.Suggestion
Improve this
ApplicationModules:getModulesByType
in order to take the finest/deepest module for a type, which would be in my caseorg.myapp.a.b