I have some problems importing a Java project into my workspace. I am following this tutorial - however I can not use the final Import existing projects step because the GIT repository I use does not include the Eclipse specific .project
and .classpath
files.
Therefore the project is not recognizes as project and hence can not be imported. Therefore I tried my luck using the option Use the New Projects wizard and select "Java Project" in the next dialog. The problem is that this creates a new Java project without any content! The project is also not connected to the GIT repository.
Edit: This is a known bug of eGIT: Bug 324145 - Project import doesn't work for abitary project types - if you want this problem fixed vote for it...
If I use Import as general Project Eclipse always wants to use the external repository directory as project directory which is not what I want and additionally the created Project is not Java-enabled.
Therefore I am asking why it is so complicated to import a Java project into Eclipse using eGIT?
It is possible by first cloning the repository and then creating a General project based on that. Then you can convert it to Java project. Here is how:
File
>Import...
>Projects from GIT
.Select a Git Repository
view you first press Clone
. And follow instructions. This will create a local "checkout" of the repository to your computer. You can set the folder to be your workspace so it looks like any other of your eclipse projects. Import
-view. Now you can select the repository you just cloned from the list. Next
and select Import as General Project
. Now you have a git repository to eclipse. nature
and buildCommand
elements from other Java project to your .project
file:Relevant sections from .project
:
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
Then from Project>Properties>Java Build Path>Source add your source folders (and possible libraries).
Edit: Added the conversion to Java project.