如何将GIT非Eclipse Java项目导入Eclipse? [英] How to import a GIT non-Eclipse Java project into Eclipse?

查看:392
本文介绍了如何将GIT非Eclipse Java项目导入Eclipse?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Java项目导入到我的工作区中有一些问题。我正在关注本教程 - 但是我无法使用最终的导入现有项目步骤,因为我使用的GIT存储库不包括Eclipse特定的 .project .classpath 文件。 / p>

使用新建项目向导



因此,项目不能识别为项目,因此无法导入。因此,我尝试使用选项使用新建项目向导并在下一个对话框中选择Java Project。问题是这创建了一个没有任何内容的新的Java项目!
该项目也没有连接到GIT存储库。



编辑:这是一个已知的eGIT错误:错误324145 - 项目导入不适用于无效的项目类型 - 如果您希望此问题固定投票...



作为一般项目导入



如果我使用导入作为一般项目,Eclipse总是希望使用外部存储库目录作为项目目录不是我想要的,另外创建的项目不启用Java。



所以我问为什么使用eGIT将Java项目导入到Eclipse中是如此复杂?

解决方案

可以首先克隆存储库,然后根据这个创建一个General项目。然后可以将其转换为Java项目。以下是如何:




  • 首先转到文件> 导入... > GIT的项目

  • 中选择一个Git Repository 查看您首先按克隆。并遵循说明。这将创建一个本地检出的存储库到您的计算机。您可以将文件夹设置为工作区,使其看起来像任何其他eclipse项目。

  • 克隆存储库后,您可以回到导入 -view。现在,您可以从列表中选择刚刚克隆的存储库。

  • 点击下一步,然后选择导入为一般项目。现在你有一个git存储库eclipse。

  • 将其转换为Java项目:从其他方面添加 nature buildCommand Java项目到您的 .project 文件:



<$ c中的相关部分$ c> .project :

 < buildSpec> 
< buildCommand>
< name> org.eclipse.jdt.core.javabuilder< / name>
< arguments>
< / arguments>
< / buildCommand>
< / buildSpec>
< natures>
< nature> org.eclipse.jdt.core.javanature< / nature>
< / natures>

然后从项目>属性> Java构建路径>源添加您的源文件夹(和可能的库)。



编辑:将转换添加到Java项目。


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.

Use the New Projects wizard

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...

Import as general Project

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:

  • First go to File>Import...>Projects from GIT.
  • In the 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.
  • After you have cloned the repository you get back to Import-view. Now you can select the repository you just cloned from the list.
  • Click Next and select Import as General Project. Now you have a git repository to eclipse.
  • Convert it to Java project: Add 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.

这篇关于如何将GIT非Eclipse Java项目导入Eclipse?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆