april
april

Reputation: 131

are there different ways of importing git repository to Eclipse?

Why when I import a git project it does not appear like full package path view (main.java.comformance) like this image:

Current at left, expected at right

I have imported this project before but now in the package view, it only appears as a tree of folders and not full package path view like main.java.comformance with package icons. I wonder what I'm doing differently now. I followed the instructions in this video: https://www.youtube.com/watch?v=L8IeaWHZCRo)?

Upvotes: 0

Views: 2011

Answers (2)

howlger
howlger

Reputation: 34135

Both projects on the screenshot do not seem to be configured correctly (probably because they were not created with Eclipse or files like .project were not shared):

  • The project on the right side is obviously a Maven project (with probably this pom.xml file): the Java source folder should be src/main/java/ (default of Maven) instead of src (default of Eclipse) and the Java packages for instance uk.ac.manchester.cs.jfact instead of main.java.uk.ac.manchester.cs.jfact.
  • The project on the left side is not even configured as a Java project.

The simplest way is to use the Eclipse Smart Import feature (instead of configure everything manually): the Java nature of the project will be detected even without the .project file and also the pom.xml file is read to get the required JARs and to configure the Java build path and source folder(s) automatically:

  1. Clone the Git repository
  2. In the Git Repositories view right-click the Working Tree node and choose Import Projects...

Upvotes: 2

Alfonso Nishikawa
Alfonso Nishikawa

Reputation: 1885

Do you see the "J" in the icon next to the project name "jfact" at the right image? That means that it is a "java" project. Eclipse does not know anything about your project.

You will have to do one of this:

  • Checkout the project again with Eclipse and use a "wizard" configuring it as a java project.
  • Enable Project Facets (right-click on the project name), and then enable "Java" in the Project Properties/Facets. This is not trivial, so I don't recommend this. - If this is a solution, actually I don't know for sure -
  • If you are using maven, close the project and execute mvn eclipse:eclipse to convert/create the project files for eclipse, and open again the project.

After you manage it to become a Java project, furter steps could be needed, but maybe will be enough.

Upvotes: 0

Related Questions