Best way to set up multiple eclipse projects in one repository

I have a Java project that will be worked on as multiple eclipse projects: one client, one server, and a common area containing the classes, etc. that will be shared between them. I have it envisioned as one repository containing 3 (or 4) eclipse projects. 

Of course I could make it 3 repositories, but these will be so closely linked I think that would cause more problems than it’s worth, and they’re not going to be large enough to worry about someone wanting only a subset of the files.

My thought was to create a repository folder, call it parent, and then create a folder under that for each eclipse project, call them childA, childB, and childC. When I (or anyone) clones the repository, clone it to a folder outside the eclipse workspace. Then, in eclipse, create each project by importing the corresponding folder – assuming it’s a maven project, for instance, in eclipse do “File / Import” and choose “Maven / Existing Maven Project”, then choose (for example) childA. I’m assuming this will create an eclipse project based on the ChildA source, but leave that source in the folder to which it was cloned. It can then be managed with eGit and edited, compiled, run, debugged, etc. I would do the same with childB and childC, giving me 3 separate eclipse projects from that one repository. 

Within eclipse, I could specify the common library project as one available on the build path of both the client and server, and be off and running. At runtime, I could either create a jar for the common library or just put the common class files, etc. in both the server jar and the client jar.

Is this a good way to do this? An ok way? A best practice way? I am still learning Git, and so am open to suggestions.

tia

Hi @ralphcook,

Thank you for being here! Personally I’ve seen it done in separate or all in one, with my limited eclipse experience. Have you looked into submodules ie: embedding a repository into another? I think the best practices are definitely a personal choice when it comes to a specific project.

Hopefully, other members of the community can chime in with their experiences.

1 Like

What I finally did was create a repository with 3 folders; then made each of those folders the root of a Java project in eclipse. Without special magic, I cannot separate any of the folders from the branch I’m working on – but the three projects are so interwoven that’s ok with me.

Details: I already had the Java projects in eclipse in different folders (and in a different location than I was going to use for my local copies. I created an empty github repository, then cloned it to the folder where I wanted my local copy. Then I copied each set of sources into a folder within the repository folder. I created a new workspace (which I had wanted to do anyway). In eclipse, I did a “File / Import” of an existing java project for each folder, and I was done. Everything worked fine from there. I can back up the old folders and delete them to make sure I don’t confuse the two copies of source.

p.s. my workspace folder did not overlap the github source tree, intentionally.

1 Like