How to version control common libraries? [duplicate]
https://softwareengineering.stackexchange.com/questions/380851
-
15-02-2021 - |
Question
For example, I have multiple projects which shares some common libraries:
- ProjectA
- CommonLib1
- CommonLib2
- ProjectB
- CommonLib1
- CommonLib2
At the moment, they are all in one big repository:
- ProjectA
- ProjectB
- CommonLib1
- CommonLib2
However, I think it is better to have one repository for ProjectA
and ProjectB
. But how should I manage my common libraries? A common Repository?
The Problem I have with a common repository is: It is out of sync with the specific project repository.
E.g: I want to rollback ProjectA
. Doesn't compile. Now I need to rollback CommonLib2
. Check in. ProjectB
doesn't compile anymore, since it uses methods, which CommonLib2
has not anymore.
My main problem is: How can I keep the Specific Project and the Common Project in Sync?
At the moment I use TFS VC. If there is no good answer for it, would it be for another VCS (e.g. git)?
Solution
One simple approach is to treat CommonLib* as external dependencies - generate their deployables, store them in a separate repository, and copy them as needed into the deployables of Project*. That way, when (not if) ProjectA starts depending on a different versions than ProjectB you can easily link each of them to the specific versions of CommonLib* they support.