Reputation: 3096
I have 2 different Java projects: web based and stand alone application. Both project share some packages like: models and DAO.
I don't want to keep both projects in the same GIT repository but in the same time I would like to have one place for storing the common code. I would also like to be able to edit the common code while working on any of the two applications.
What is the best way to solve this issue? I was thinking about 3 repos: - web project - stand alone - common
and link common into web and stand alone but I worry about some potential problems of this approach.
A cleaner solution which comes to my mind is to have the common code deployed as JAR to Web/Standalone projects but then every time I will want to update Model/DAO i will have to redeploy the package (which doesn't feel ideal).
Is there a better way?
Upvotes: 0
Views: 282
Reputation: 115328
My suggestion is the following. Create 3 repositories:
Each repository will contain a single root project with optional sub-modules. The build will produce the single or multiple jars according to your needs.
Now, create yet another repository. Let's call it "all". Define previously mentioned repositories as a submodules of this one. Git supports this. You will be able to commit and push things either to specific repositories or to all repositories altogether.
Upvotes: 1