简体   繁体   English

对于IntelliJ,有什么理由要导入Eclipse项目,而不仅仅是导入Gradle项目?

[英]For IntelliJ, is there ANY reason to import Eclipse project vs. just importing the Gradle project?

I have seen many questions about importing Eclipse or Gradle projects into IntelliJ, but not a question asking which approach to use. 我已经看到了很多有关将Eclipse或Gradle项目导入IntelliJ的问题,但是没有询问使用哪种方法的问题。 I assume just import Gradle? 我假设只是导入Gradle?

We use Eclipse over Gradle, I can build and run my projects either with gradle command lines or (less likely:) in Eclipse. 我们在Gradle上使用Eclipse,我可以使用gradle命令行或在Eclipse中(不太可能:)来构建和运行项目。 As long as I can build with gradle on the command line my boss is happy. 只要我可以在命令行上使用gradle构建,我的老板就很高兴。

I found the fully-enabled free student versions of IntelliJ/Jetbrains products, so I am using the Ultimate version 15.02. 我找到了功能全面的IntelliJ / Jetbrains产品的免费学生版本,因此我使用的是Ultimate版本15.02。 Gradle 2.8 FWIW. Gradle 2.8 FWIW。

Is there ANY reason to import the Eclipse project vs. just importing the Gradle project? 与导入Gradle项目相比,有什么理由要导入Eclipse项目吗? And I guess in the last couple versions of IntelliJ you just open the Gradle file, not import a Gradle project? 我想在IntelliJ的最后几个版本中, 您只是打开Gradle文件,而不是导入Gradle项目?

Also still a good idea to leave auto-import turned off? 关闭自动导入还是个好主意? And I notice putting apply plugin: 'idea'; 而且我注意到放了apply plugin:'idea'; in build.gradle is no longer necessary since version 14. 自版本14起,不再需要 build.gradle中的内容。

I'm not an expert in the differences from importing from Eclipse vs Gradle, but I would always import from Gradle when possible (this is true for Maven and Ant base builds as well). 我不是从Eclipse vs Gradle导入的区别专家,但是在可能的情况下我总是会从Gradle导入(对于Maven和Ant基础版本也是如此)。

Which datastructure do you want Intellij to use to figure out where your sources are? 您希望Intellij使用哪种数据结构来确定您的来源在哪里? You can either use the same thing Eclipse used (the build.gradle file) or you can use the product of Eclipse's interpretation of the build.gradle file. 您可以使用Eclipse使用的同一东西(build.gradle文件),也可以使用Eclipse对build.gradle文件的解释的产物。

When you import from Eclipse, you're essentially saying "Instead of getting my information direct from the build tool's setup, I'm going to get my information that got its information from the build tool." 从Eclipse导入时,您实际上是在说:“不是直接从构建工具的设置中获取我的信息,而是从构建工具中获取其信息。” You've added another layer for no real value in the import. 您在导入中添加了没有实际价值的另一层。

That said, maybe there are things that the Eclipse project settings that project import will include. 就是说,也许项目导入中将包含Eclipse项目设置。 I could imagine the Eclipse project import pulling in anything like manually included jars, but this means that your project probably requires an IDE to build it (which is terrible) and really you should refactor your project so that it can be built without any IDE assistance (from the command line). 我可以想象Eclipse项目导入会引入任何类似手动包含的jar的内容,但这意味着您的项目可能需要一个IDE来构建它(这很糟糕),实际上您应该重构项目,以便可以在没有任何IDE辅助的情况下进行构建。 (从命令行)。

So in short, import from Gradle directly. 简而言之,直接从Gradle导入。 Don't go through Eclipse. 不要经历Eclipse。 You're just filtering the source data through a filter that isn't adding any value. 您只是通过不添加任何值的过滤器过滤源数据。 Or if it is adding value, then it's probably a project specific configuration that shouldn't be done in an IDE anyways. 或者,如果它正在增加价值,则可能是特定于项目的配置,无论如何都不应在IDE中进行。

PS. PS。

I always just go to the build.gradle file and "open" that. 我总是只是转到build.gradle文件并“打开”该文件。 Same thing for pom.xml. pom.xml也是一样。

I always have auto-import on, both for Maven and Gradle based projects. 对于基于Maven和Gradle的项目,我始终会自动导入。 I've never run into any issues with it and it keeps me coding faster. 我从来没有遇到任何问题,它使我的编码速度更快。

I know, this is a fairly old question, but I just wondered the same thing. 我知道,这是一个相当老的问题,但我只是想知道同一件事。

Apparently, JetBrains recommends importing the build tool file instead of the Eclipse project when possible. 显然,JetBrains建议尽可能导入构建工具文件而不是Eclipse项目。

If your project uses a build tool such as Maven or Gradle, we recommend choosing the corresponding option when prompted in the Import Project wizard, and selecting the associated build file (pom.xml or build.gradle) IntelliJ IDEA 2017.2 Help 如果您的项目使用诸如Maven或Gradle之类的构建工具,建议在“导入项目”向导中提示时选择相应的选项,然后选择关联的构建文件(pom.xml或build.gradle) IntelliJ IDEA 2017.2帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM