Search code examples
integration-testingspring-roomulti-module

Spring Roo propper multi-module-based layering


Spring roo supports multi-module projects and there is some stuff in examples and documentation but it looks like it's not too flexible.

I decided to split the project in module per layer: model, repository, service, web and keep integration tests either in the service module or in a separate integration module.

Although Roo has a basic support for multi-module projects, in their examples layers are split in such a way that the service, model and repository exists in one module (core) and the mvc stuff in another module, so I didn't find an example of splitting the layers to module per layer.

The first problem I had with my approach was that I had to define the jpa setup in both modules: model (has the jpa annotations) and repository (has the jpa functionality).

The second issue which is kind of a blocker, is that I ended up having cyclic dependencies: the service & repository modules are using the model module but on the other hand, the model module has the integration tests (auto-generated) which use the service and repository modules.

Is there any way to move the integration tests out of the model module and have them either in the service module or in a separate module and do that while being Roo compatible?

By default Roo adds the integration tests in the same module where the model exists and I didn't find a way to ask Roo to put the tests somewhere else.


Solution

  • It looks like Roo doesn't support such functionality yet.

    First of all, the implemented multi-module functionality is simpler than expected.

    Secondly, the flexibility on configuring the place of the integration tests doesn't exist even for different folders inside the same module/project.

    The only workaround which works is having the project in two versions: single module (the roo version where the changes will be done) and the manual multi-module (not roo managed, where the packages will be the same like the single-module) where the changes to the single-module will be merged.