简体   繁体   中英

How to import build.gradle into IntelliJ

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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