Reputation: 14289
Our rest service development is handicapped and slowed down with current structure. I have tried to capture it in a picture below. Some explanation about the diagram
Most of the code is under v1 or v2. RestServiceA/B don’t have much code in them apart from resources, configurations etc. So, there is a tight coupling here.
Problem with this approach is that, for a given feature I make changes in let’s say v1, I need to build the jar, update its version in let’s say RestServiceA and test. This needs to repeat for every new commit. Additionally, I would need to publish my own snapshots to test outside of local.
To avoid this mess, I was thinking of using github submodules. However, my knowledge is limited. Can someone help if below understanding is correct and if I am missing any obvious loopholes if were to choose this approach. I’m open to any alternative approach. Thanks!
Upvotes: 1
Views: 1957
Reputation: 8958
We have a similar project structure and ended up with the following solution.
v1-lifecycle, v1-utils, v2-lifecycle, v2-utils, prd-common, RestServiceA, RestServiceB, RestServiceC
pom.xml
includes all other modules in its trees using Maven's <modules>
tag: <modules>
<module>module1</module>
...
<module>moduleN</module>
</modules>
And the tree structure of the parent repository looks like:
├── module1
├── ...
├── moduleN
└── pom.xml
This allows us to build and test all the projects before committing and before publishing the artifacts using mvn test
, mvn integration-test
, or mvn package
.
Also this architecture makes cross-module refactorings much easier as IDE opens all the code. So we do all the development from the parent repository directly.
I wrote an article describing this setup on a tiny example of just 2 modules.
Here comes full disclosure: the project we're developing is Git X-Modules (is a replacement to Git submodules) and it uses itself instead of Git submodules to insert module repositories into the tree of the parent repository.
So by inserting module repositories into the parent repository I mean using of either:
to create module1
...moduleN
directories at the root of the parent repository.
The difference is that in case of Git submodules the module1
...moduleN
directories at the root of the parent repository will be links to their corresponding Git repositories. E.g. if we change them from the parent repository, we have to commit and push into each of the individual module repository.
In case of Git X-Modules they all be just normal Git directories, so we have to commit and push only once, and on the server side the push is converted to pushes into individual module1
...moduleN
repositories. I hope you get the idea. The branching is also easier in this case.
Regarding your last question, afaiu this was needed because you don't want to test changes before committing them. When having the parent repository with Maven modules, you can just run "mvn test", "mvn integration-test", or even perform manual testing of all the changes before committing and pushing, so the question becomes irrelevant, as I understand.
In the worst case the developer can create a new branch directly in the parent repository and push just that branch to make CI test it and then merge the branch (or cherry-pick from it) it everything is ok. No temporary upload to Maven is involved.
Upvotes: 1