0

I am trying to combine spring modulith (1.3.4) and clean architecture to verify the proper dependencies between gradle modules. The project setup is defined by the following structure:

Domain

Logical name: xx.services.domain Base package: xx.services.domain

Adapters

Logical name: xx.services.adapters Base package: xx.services.adapters

Infrastructure

Logical name: xx.services.infrastructure Base package: xx.services.infrastructure

Bootstrap

Logical name: xx.services.bootstrap Base package: xx.services.bootstrap

Each package is defined on its own gradle module and has additional subpackages.

In order to achieve the clean architecture dependencies for the bootstrap module that is supposed to have access to all other modules, a package-info.java is required with the following content:

@NamedInterface(value = "xx.services.bootstrap")
@ApplicationModule(allowedDependencies = {"xx.services.domain",
        "xx.services.domain :: Gateways",
        "xx.services.domain :: Repository",
        "xx.services.domain :: Presenter",
        "xx.services.domain :: UseCase",
        "xx.services.domain :: Interactor",
        "xx.services.domain :: ServiceGateways",
        "xx.services.adapters",
        "xx.services.adapters :: Grpc",
        "xx.services.adapters :: RestService",
        "xx.services.adapters :: Presenter",
        "xx.services.infrastructure"})
package xx.services.bootstrap;

import org.springframework.modulith.ApplicationModule;
import org.springframework.modulith.NamedInterface;

Where all explicit named interfaces under each module has to be defined by annotating the java class with

@NamedInterface(name = "Presenter")

This produces the following diagram: enter image description here

Is there a way to mark a specific gradle module and all its subpackages such as the domain one which is supposed to be allowed to be accessible by all other modules as allowed?

Tried with "xx.services.domain :: *" but didn't work.

1
  • Doesn't the bootstrap module have to depend on everything anyway? If so, why list dependencies explicitly in the first place? That said, the wildcard syntax should work. Can you clarify what “didn't work” means? Happy to look at a small reproducer project, too. Commented Apr 4 at 7:21

1 Answer 1

0

The purpose of Spring Modulith is to have everything in the same module as it's a monolithic application, effectively using ArchTest to validate architectural rules and boundaries with events for communication between ApplicationModules.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.