spring-projects / spring-projects/spring-modulith

Allow nested packages for @Modulith(sharedModules)

Open
#524 5 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Mar 8, 2024.

meta: waiting for feedback
Dominant language
Java
Stars
1.2k
Forks
222
PR merge metrics
No merged PRs in 30d

Description

Current Behavior
The sharedModules parameter of the @Modulith annotation does not allow nested packages, even when the nested packages are explicitly listed.
package structure - com.app.core.exception

@Modulith(sharedModules={"com.app.core"}, useFullyQualifiedModuleNames = true) and @Modulith(sharedModules={"com.app.core", "com.app.core.exception"}, useFullyQualifiedModuleNames = true) result in java.lang.IllegalArgumentException: Module com.app.core.exception does not exist!

@Modulith(sharedModules={"com.app.core"}, additionalPackages = { "com.app.core.exception"}, useFullyQualifiedModuleNames = true) results in
Module 'com.app.user' depends on non-exposed type com.app.core.exception.EntityNotFoundException within module 'com.app.core'!

Desired Behavior
Allow for wildcard(1) or explicitly listed(2) sub-packages to be referenced within all modules.
1 @Modulith(sharedModules={"com.app.core.*"}, useFullyQualifiedModuleNames = true)
2 @Modulith(sharedModules={"com.app.core", "com.app.core.exception"}, useFullyQualifiedModuleNames = true)

Workaround
change package structure to com.app.core and com.app.exception with @Modulith(sharedModules={"com.app.core", "com.app.exception"}, useFullyQualifiedModuleNames = true)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.