Git – Importing multiple maven projects from git into eclipse

eclipsegitm2em2eclipsemaven

I've got a git repository with two Maven projects "foo" and "bar". The structure of the cloned repo is as follows:

myrepo
  .git
  foo
    pom.xml
  bar
    pom.xml

What I want

Two projects "foo" and "bar" in my workspace with maven nature and working Team menu.
I'm running Eclipse 3.7 with m2e 1.0.0.

I tried the following:

Import -> Check out maven projects from SCM

This clones the repo into a new folder in my workspace folder and imports the two projects, but without connection to git (Team menu is mostly empty).

Import -> Projects from Git

With this option I can only import the entire repo as a single general project (with working Team menu). If I then use "Import -> Existing maven projects", the projects foo and bar are imported but without working Team menu.

Is it possible at all to import multiple projects from a git repo with working Team menus?

Best Answer

As far as I know and are able to perform on my setup (Eclipse 3.7, Egit 1.0.0, m2e 1.0, m2e-egit 0.13), it is not possible in a single step. The cleanest procedure that I know of is the following:

  • Clone your Git repository (preferably from Eclipse, otherwise you also need to add the repository to the Git Repositories view);
  • Import -> Check out existing Maven projects from the root folder of your cloned repo;
  • Select all the resulting Eclipse projects, and choose Team -> Share project;
  • Now select Git and check Use or create Repository in parent folder of project.

Long-winded? Sure. But cloning beforehand gives you control over the folder name you check out to, in contrast to Check out Maven projects from SCM which on my machine produces a "maven_{unix_timestamp}" like folder name.

I agree wholeheartedly with you that a quicker procedure should be available.