如何将build.gradle导入到IntelliJ中 [英] How to import build.gradle into IntelliJ
问题描述
注意:此
然后右键点击 src / main / scala
目录,注意到没有用于添加Scala源文件包的选项。或者任何JVM( .java
等)文件:
我认为Gradle Init插件是有缺陷的(对于 scala-library
类型至少)或Gradle IDEA插件存在缺陷。无论哪种方式,我认为我在我的一个IntelliJ项目文件中缺少一些东西:
- IML;或
- IPR;或
- IWS
任何想法我都可以更改,以便IntelliJ显示编译器错误等我可以添加新的Scala源文件?
gradle idea
命令生成IntelliJ IDEA项目文件不被推荐,它会创建传统的格式项目文件,并且在大多数情况下,项目将无法正常工作(它只适用于基本的Java项目)。 这种生成IntelliJ IDEA项目的方式已被弃用,您应该在IntelliJ IDEA中打开 build.gradle
文件(这与使用Import并指定构建文件位置相同)。
将Gradle项目模型映射到IntelliJ IDEA项目模型非常复杂,并且由JetBrains开发人员使用Gradle API进行维护和支持,而 gradle想法
是由Gradle开发人员添加的,不再被主动维护。
NOTE: Full source code for this is here.
I used the Gradle Init plugin to create a Scala library:
gradle init --type scala-library
Then I modified its build.gradle
to generate a wrapper for Gradle 2.13. Then I ran:
gradle wrapper
To generate the wrapper. And then finally I ran:
./gradlew clean idea
I opened this project in IntelliJ Community. I modified the Library.scala
(that the Gradle Init plugin creates) to contain obvious Scala compiler errors, but noticed the errors weren't showing up in red underlines:
I then right-clicked the src/main/scala
directory and noticed there's no options for adding packages of Scala source files. Or any JVM (.java
, etc.) files for that matter:
I think either the Gradle Init plugin is flawed (for scala-library
types at least) or the Gradle IDEA plugin is flawed. Either way, I think I'm missing something in one of my IntelliJ project files:
- IML; or
- IPR; or
- IWS
Any ideas what I can change so that IntelliJ displays compiler errors and so that I can add new Scala source files?
Using gradle idea
command to generate IntelliJ IDEA project files is not recommended, it creates legacy format project files and in most cases the project will not work correctly (it will work only for basic Java projects).
This way of generating IntelliJ IDEA projects is deprecated and you should just open build.gradle
file in IntelliJ IDEA (it's the same as using Import and specifying the build file location).
Mapping Gradle project model to IntelliJ IDEA project model is really complicated and is being maintained and supported by JetBrains developers using Gradle API, while gradle idea
was added by Gradle developers and is no longer actively maintained.
这篇关于如何将build.gradle导入到IntelliJ中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!