Importing a Maven project into Eclipse from Git

Arthur Ulfeldt picture Arthur Ulfeldt · Feb 2, 2011 · Viewed 119.2k times · Source

How can I get the effect of choosing to import from both Maven and Git and have Eclipse properly generate my project?

To get my project into Eclipse I can choose File->import->maven and then I get all the Maven projects imported and can build fine, or I can choose File->import->git and make a new project that ignores the pom.xml and does not generate the project properly.

It seems I can do one or the other but not combine both so I get a correctly generated project.

Answer

Sri Sankaran picture Sri Sankaran · Sep 1, 2011

Eclipse Indigo + M2Eclipse 1.0 makes it very easy.

If you don't already have the Git connector for M2Eclipse install it. M2Eclipse will help you along by prompting you on the Import menu.

  1. Select the "Import..." context menu from the Package Explorer view
  2. Select "Check out Maven projects from SCM" option under the Maven category
  3. On the window that is presented choose the link "Find more SCM connectors in the m2e Marketplace
  4. Find connector for Git...install...restart

Note that in the search box you may have to enter "EGit" instead of "Git" to find the right connector.

With that done, simply go to the EGit repository, bring up the context menu for the Working directory and select "Import Maven projects...".

Done!