13

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?

Jens Theeß
  • 580
  • 1
  • 3
  • 15

3 Answers3

13

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.

Luca Geretti
  • 10,206
  • 7
  • 48
  • 58
  • I wasn't aware that I could use "Share project" to reconnect the project to its local git repo, thanks. I also found a bug report for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=346098 – Jens Theeß Sep 19 '11 at 10:28
  • Good to know. Let's hope for a quick fix then. – Luca Geretti Sep 19 '11 at 11:18
  • 2
    According to Bug 346098, EGit 1.2 has the option to auto-share imported projects. To be found under Preferences -> Team -> Git -> Projects. – Jens Theeß Jan 25 '12 at 16:01
  • I still have some issues making EGit > 1.0 integrate with both m2e and the mylyn GitHub connector, so I am stuck with the 1.0.0. – Luca Geretti Jan 25 '12 at 16:34
  • I just set up a new Eclipse and now the auto-share is _on_ by default and it didn't work properly with our projects. egit should _not_ be on the marketplace if it can get such updates – Thorbjørn Ravn Andersen Feb 27 '13 at 14:36
4

Here are the steps I used (using eclipse helios, egit and maven plugins)

  1. From git repo perspective, clone your repo (I'm pulling in git://git.springsource.org/spring-security/spring-security.git for example)
  2. Use "Import -> Projects from Git" to import as single general project.
  3. On this project use "Import -> Existing Maven project" to import separate subprojects.
  4. On each new project, go to "Team -> Share Project -> Git".
  5. If desired, remove the original project imported in step 2 above. Just remove from workspace, don't remove disk contents.
0
  1. Create Clone of your Git repository. This can be done by choosing option of clone in'Git Repo Perspective' in eclipse. It will create a local repository in your system. I used bitbucket (GIT) to host my code. It will create a repository with the same name as you have given while creating the repository at your host. At this point of time an empty repository will be created since I have not put anything at host as of now.
  2. Now copy your multimodule Maven project to the local repository which is created in step 1.
  3. Go to eclipse, now click on import --> Projects from GIT -->Existing local Repository -->select your local repository --> import existing projects and we are done.
  4. You will see '?' on your modules. Now select all the projects --> Team -->share projects-->Add index. You will see '+' sign. Now commit and push your changes.
    In my case, I have not created the repository at host before hand. I created it through eclipse by pushing the code from my local to host. Vice versa can be done by cloning. If your code is already present at the host, cloning will fetch the code and save it in your local repository and similar steps can be executed to import project into eclipse workspace.
Ankit Pandoh
  • 548
  • 5
  • 14