smeeb
smeeb

Reputation: 29587

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:

enter image description here

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:

enter image description here

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:

Any ideas what I can change so that IntelliJ displays compiler errors and so that I can add new Scala source files?

Upvotes: 2

Views: 10928

Answers (1)

CrazyCoder
CrazyCoder

Reputation: 402591

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.

Upvotes: 14

Related Questions