4

I have forked this project on my GitHub:

and now I'm trying to import (clone) my own origin repo locally. I managed to do it via Bash command line, but I'm not being able to import the project in Eclipse and make it a "Java Project". It's imported as a "Generic project" where packages are seen as plain directories:

enter image description here

The import wizard gives these 3 options:

enter image description here

If I go with the first one it says "No projects found" and if I go with the second I have no idea how to proceed.

Is this the wrong way to go? I'm using Eclipse Mars (4.5.1) with EGit plugin.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Luigi Cortese
  • 10,841
  • 6
  • 37
  • 48

2 Answers2

6

What you are trying to import is actually a Maven project. First of all, make sure you have M2Eclipse installed, so that the projects can be imported and built automatically.

What I usually do in those cases is the following (pictures are taken with Eclipse Mars 4.5.1, you will need to adjust with your Eclipse installation but it shouldn't change much):

  • Clone the Git repository with the URL: https://github.com/iluwatar/java-design-patterns.git.

    enter image description here

  • Select the master branch only

    enter image description here

  • Once Eclipse has downloaded everything, I do not use the import facility but instead let Eclipse finish and do nothing.

    enter image description here

At this point, there are 2 approaches possible. The repository is checked out into your machine, and the projects need to be imported in Eclipse as Maven projects.

Solution 1: Import as Maven project from the Git perspective

NOTE: this solution requires the m2e-egit connector to be installed. Refer to this answer to locate and install it. The connector will be located at the bottom of the list, below the "m2e Team providers" section, and is named m2e-egit.

  • Still in the Git perspective, expand the Git repository, right-click "Working Tree", and select "Import Maven Projects..."

    enter image description here

Solution 2: Import as Maven project from the Import facility

  • Go to "File > Import... > Existing Maven Projects".

    enter image description here

In both of those cases, you will be greeted with the following dialog, where you can select all the Maven projects you just downloaded and import them.

enter image description here

Community
  • 1
  • 1
Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • It worked like a charm, but imported 66 projects to my workspace... I should have expected it, right? – Luigi Cortese Nov 01 '15 at 18:35
  • @LuigiCortese Well, it has imported all the Maven modules of this project. So... yes :) – Tunaki Nov 01 '15 at 18:37
  • 1
    This is why it took almost half an hour on my old Toshiba... =) I've found [this](https://github.com/OneBusAway/onebusaway/wiki/Importing-source-code-into-Eclipse) resource in the meanwhile, if you want to add it to your answer it may be helpful to someone else. Thanks a lot! – Luigi Cortese Nov 01 '15 at 18:39
0

Since your project seems to be using pom.xml, use Maven's eclipse plugin to create an Eclipse project.

asgs
  • 3,928
  • 6
  • 39
  • 54