spring-modulith icon indicating copy to clipboard operation
spring-modulith copied to clipboard

Documentation contains invalid information

Open luciano-fiandesio opened this issue 1 year ago • 2 comments
trafficstars

The "Fundamentals" section of the documentation contains a section about Open Modules that seems to be incorrect.

The example does not compile:

@org.springframework.modulith.ApplicationModule(
  type = Type.OPEN
)
package example.inventory;

since the org.springframework.modulith.ApplicationModule annotation has no type attribute.

luciano-fiandesio avatar Jun 21 '24 12:06 luciano-fiandesio

It has.

odrotbohm avatar Jun 21 '24 18:06 odrotbohm

It has.

It has indeed 😵 … I was using version 1.1.3. Sorry about that.

Since we are here, I have one question. I would like to introduce Modulith in an existing project that is already partially organized in logical modules. The monolith has a first-level common package, which contains a number of subfolders that are used for various "common" things, e.g. superclasses for rest controllers, events, etc. Is using Type.OPEN to allow this pseudo-module to be accessed from the other modules?

From the docs, it seems that is also possible to achieve a similar result using the additionalPackages attribute of the @Modulithic annotation. Which of the two approaches is the more correct to allow a package and its subpackages to be accessed by multiple modules? Thanks!

luciano-fiandesio avatar Jun 21 '24 20:06 luciano-fiandesio

An open module would be the way to go here. The Javadoc of additionalPackages clearly states (emphasis mine):

Defines which additional packages shall be considered as modulith base packages in addition to the one of the class carrying this annotation.

odrotbohm avatar Sep 03 '24 06:09 odrotbohm