smeeb smeeb -4 years ago 237
Scala Question

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
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
(that the Gradle Init plugin creates) to contain obvious Scala compiler errors, but noticed the errors weren't showing up in red underlines:

enter image description here

I then right-clicked the
directory and noticed there's no options for adding packages of Scala source files. Or any JVM (
, etc.) files for that matter:

enter image description here

I think either the Gradle Init plugin is flawed (for
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download