Sharing a module across two projects
Answered
I have a number of Java REST service projects that have use a common jar file. There are separate repos for each service and a separate repo for the jar. All these repos are Maven projects with their own POMs.
As we are in early stages of development, it's very very common as we develop a "service" to make changes in the COMMON jar. I'm trying to make a "recommendation" to our developers on how to setup their projects so they can easily jump between service projects, and yet make changes to COMMON.
I can imagine the following options:
- Have a separate project for each service that includes a "module" for the COMMON jar project.
What I'm unclear on here is whether an "existing sources" IDE module can be "shared" between two IDE projects. When I tried adding the COMMON as a module to one project, it seemed to render useless another project for which it was already a module. I'm not sure if the IDE doesn't support a "shared module", or if I just screwed up. I suppose a workaround might be to create a git worktree (for the COMMON project) for each service I want to include it in . Worktrees can be a minor PITA though.
- Have a "monolithic" project where I have all my service repos as "modules" as well as a COMMON module.
This avoid the need to have a shared COMMON module, but I'm not crazy about this because it means switching to-and-from working in one service isn't quite so easy. And it seems like it might be a minor nuisance to have to avoid having refactors, builds, etc done for ALL the services that I'm not working on at the moment.
So... I'm just looking for some guidance here, and in particular, whethere it is indeed possible to have an InteeliJ module that is "shared" between to IDE projects.
Please sign in to leave a comment.
Hello,
Sorry for the delay. Seems the first option should work fine. You have separate project with "COMMON" library and add it as an additional module to existing project.