What is the best practice to work with several Java modules from different GitHub sources using IntelliJ?
This might be an odd qeustion but I do not know what the standard workflow is to achieve what I have in mind.
The current situation
I develop a Java project with IntelliJ and I manage my code with GitHub. The project is currently stored in a private repository on GitHuband it consists of several independent Maven modules. This is a sample structure:
The plan
Now I plan to publish only ModuleB on a public repository on GitHub. I want to share only this module and allow others to use it. What is the best practice so that I can develop Module B further within my project and all changes get published in the public repository? I do not know how to do this in IntelliJ. I am insecure about the workflow here or is there another pattern which I could follow to achieve this?
Idea
I think I could export ModuleB, import it as a separate public repository into GitHub and then send pull requests when I make changes. But how do I do this with IntelliJ? How can I fork the public repository into my existing project, which is itself shared in a privare repository? Can I nest GitHub projects? Is this a good idea after all? Please let me know if my question is clear.
Further clarification
I know that I can import several "modules" in IntelliJ, but this is a different thing, isn't it? An IntelliJ module is the same as an Eclipse project, which is an independent entity. I think I could solve the problem with this approach, but then I would have to commit the overall project seperately. Could this be solved more elegantly with Git submodules perhaps?
Proposed Solutions
My created a new GitHub repository for ModuleB and uploaded the source code to it. This module is now set as public and independent from the main project.
Use IntelliJ import Module
Instead of trying to integrate the "external" repository directly into my current project, I cloned the ModuleB repository to a different directory. Then I imported the said folder as a new module in IntelliJ.
IntelliJ then asks if there sould be a dependency between the newly added ModuleB. Unfortunately this only adds an entry into the .iml file
<orderEntry type="module" module-name="Submodule" />
and not into the pom.xml file. So this information where to obtain the source for the module is only available in IntelliJ. How could this problem be addressed? I only tried it with a toy project so far, but if someone wants to import the whole project into Eclipse for instance, this might cause a problem. How could I reference the other GitHub repository in a useful way?