Setting Scala SDK in IntelliJ properly

(Spencer Judge) #1


I have a multi-module gradle project where all of them are a mix of java/scala. I’ve got everything working hunky-dory with gradle, but when I reimport in IntelliJ it blows away the scala SDK setting, making everything fail to compile in IntelliJ until I go in and set the SDK by hand on each project, and then rebuild. This is a pain any time I make a change to my gradle files that requires a reimport in IntelliJ.

I’m not really doing anything custom in my gradle configs with the scala plugin, just setting some source sets (and that works fine).

This is in my top-level file:

allprojects {
    apply plugin: 'maven'
    apply plugin: 'idea'
    apply plugin: 'nebula.lint'
... elided ...

subprojects { subproj ->
    apply plugin: 'java'
    apply plugin: 'scala'
    apply plugin: 'jacoco'
    apply plugin: 'scalaStyle'

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

The subprojects don’t have anything scala-specific in them besides one or two sets a generated sources dir.

Which according to

Seems like all I need to do to get it working properly, but it’s simply not setting the Scala SDK. Am I doing something wrong or is this just a bug?

I’m happy to provide more of the gradle files if necessary.