Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Android projects with same GIT submodule

I recently wanted to adopt submodules from GIT with my Android projects but stumbled into some problems.

Backstory

I have multiple projects but many use the same external library (Android library-project), in order to make the GIT cleaner and make the GIT for each project contain all the needed material I though of using GIT sub-modules for the Android library project. This part works fine I got the library included as a sub-module for the projects.

Issue

But Android uses these library-projects which basically is a regular project which is added to the project and I can only add the same project once in Eclipse. So if I need to work on more than one project at a time I have to use multiple instances of Eclipse/workspace instead of using Eclipse the regular way.

Is there a way to have only 1 instance of my library project in eclipse and at the same time have all the projects reference to their respective libraries? Or any other suggestions how I should handle this?

Any help is very appreciated

like image 755
Warpzit Avatar asked Nov 02 '22 23:11

Warpzit


1 Answers

You cannot have the library project as a single instance in Eclipse for the following reason.

  • Each project which uses the library might reference a different version of the library. Since your submodule is a physical checkout (working directory) of a particular version there is no way to represent more then one state of the repository at a certain point in time.

Workaround:

  1. Prepare a "server" location for the library project. It is good enough to create a clone using git clone --bare.
  2. Clone the "server" library project into your workspace.
  3. Prefix the library project to reflect the name of the main project it is used in.
  4. Repeat step 2 and 3 for each main project you need the library to work with.
  5. Everytime you do changes in the library project create a feature branch. In each main project consider if the new feature might be useful or hindering. If it does not fit you obviously need to rewrite the feature you just created. When you are done update the version of the library (don't be shy using tags with Semantic Versioning).
like image 129
JJD Avatar answered Nov 08 '22 05:11

JJD