IntelliJ complains with the following exception when I try to make my project.
Error:scalac: \'jvm-1.8\' is not a valid choice for \'-target\'
Error:scalac:
If you're using JDK 1.8 as your IntelliJ Project SDK, then the default project language level and source compatibility may be set to version 8 by default. This will also be reflected in IntelliJ's Scala compiler settings.
To override default Java 8 language level, it was only necessary for me to add the following to my build.gradle:
sourceCompatibility = 1.7
After doing that, make IntelliJ IDEA import the Gradle project again. You should then confirm that the change has been picked up by IntelliJ by checking under: Settings -> Build, Execution, Deployment -> Compiler -> Scala Compiler
Look at the Additional compiler options field for each of the modules listed and make sure that it contains -target:jvm-1.7, and not -target:jvm-1.8.
Under Project Settings -> Modules, you should see that the Language Level is now set to 7 too.
N.B. Setting the sourceCompatibility property under the Gradle properties allprojects, subprojects or using tasks.withType(ScalaCompile) did not work for me; it had to be specified separately to be picked up.
(This worked for me using IntelliJ IDEA 2017.2.3, Gradle 4.1, the Gradle Scala plugin and Scala version 2.10)