Is there a way to use different Repository for a specific maven module project?

Viewed 676

I've a maven multi module project in following structure. Our project is in GitHub corporate page.

I'm planning to make one of the maven module project public to let it be open source. However, because of maven multi-module project structure it needs to be under parent project hierarchy in file system, isn't it ?

What I want to do is creating a separate repository for publicModule2 and pushing it to public repo. It'll be an open source project. The rest will remain the same. Is there any way doing it without breaking maven multi module project structure ?

-- Maven parent project

  • -- commonsModule
  • --cusomModule1
  • --cusomModuleN
  • --publicModule2

P.S.As you know when you remove it from modules they're not compiling together each time and I don't want this. Without module structure I already separated another project but I don't look for that for this project. Please consider this in your reply

1 Answers

If you are serious about making it open source, that includes giving people an easy, reproducible way to build it. If it is required to be built as part of a larger project which they don't have access to, they won't be able to do that.

What you are looking for is possible with Git submodules. You would need to make the public one a submodule of the original parent.

From the docs, this feature is to be used when

you want to be able to treat the two projects as separate yet still be able to use one from within the other.

However I would strongly advocate separating the projects so that the public one can be built independently.

Related