Skip to content

Allow detecting NamedInterfaces programmatically #1009

Closed
@PinkMoustacheMan

Description

@PinkMoustacheMan

Proposal

Sprign Modulith already allows for customizing the ruleset to detect modules in your application (ApplicationModuleDetectionStrategy).
I think it would be a good idea to also allow adding custom rules to detect (and name) NamedInterfaces.

Why would this be a good feature?

Many REST APIs (and also other types of Spring applications) seem to use a slightly different package structure than the one being proposed by Spring Modulith currently.
Spring Modulith assumes all publicly exposed classes should be at the root level of the module and all internal classes should be in an internal package. However, a common way of structuring Web applications is to add subpackages to the root module's package which contain mappers, services, models, repositories and controllers respectively. These packages in many cases would be considered part of the public API, but because they are nested inside of another package, Spring Modulith does not recognize them as such.

Why the current way of declaring NamedInterfaces this is sub-optimal

The current way to "fix" this issue is to add a class (usually a package-info.java) that is annotated with @NamedInterface. This however puts a lot more visual clutter into a codebase if included in every package that needs it (~5 per domain).
A more centralized way of declaring rules as to when a package should be considered a named interface would be one way of reducing this clutter, very similar to the ApplicationModuleDetectionStrategy for module detection.

Metadata

Metadata

Assignees

Labels

in: coreCore module meta modeltype: enhancementMajor enhanvements, new features

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions