Skip to content

Check the module structure with Spring Modulith - #37

Merged
MCCProgrammer merged 2 commits into
mainfrom
test/modulith
Oct 28, 2026
Merged

MCCProgrammer merged 2 commits into
mainfrom
test/modulith

Conversation

@MCCProgrammer

Copy link
Copy Markdown
Owner

What

  • Spring Modulith 2.1.1: spring-modulith-api gives the @ApplicationModule annotation, and spring-modulith-starter-test runs the check, in test scope only.
  • Allowed dependencies: every module's package-info.java now declares which modules it may use, @ApplicationModule(allowedDependencies = ...). The lists are exactly what the code uses today. store and auth depend on no other module.
  • ModularityTests: each top-level package is a module. ApplicationModules.verify() fails on a cycle between modules, or on a dependency that isn't in the module's list.
  • Docs:
    • README: the module map as a Mermaid diagram (rendered and checked), and a line in the engineering highlights.
    • ADR 0002: the modular monolith is now checked by a test, not only intended.

Checks

  • On today's code the test passes, with no cycles. The structure was already clean.
  • I removed stats from publicpage's list on purpose, and the test failed with: "Module 'publicpage' depends on module 'stats' via PublicPages -> StatsService. Allowed targets: auth."
  • ./mvnw verify passes: 180 tests.

Each feature package is a module; ModularityTests fails on a cycle between modules or on
a dependency a module's package-info doesn't allow (@ApplicationModule). The structure
already had no cycle; the allowed lists are what it uses today, so a new dependency
between features is now a reviewed one-line change.
Both sides added a property and a managed dependency in the same places of pom.xml
(the pinned Swagger UI from #36, the Spring Modulith BOM here); kept both.
@sonarqubecloud

Copy link
Copy Markdown

@MCCProgrammer
MCCProgrammer merged commit ab97b28 into main Oct 28, 2026
10 checks passed
@MCCProgrammer
MCCProgrammer deleted the test/modulith branch October 28, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant