How to set the language level in Gradle ? (so it is IDE-agnostic)

The way to do this for CLI builds is shown. However I'm not sure if every IDE will pick this up.

allprojects {
    tasks.withType(JavaCompile) {
        sourceCompatibility = '1.7'
        targetCompatibility = '1.7'
    } 
}

If you use Gradle in command line, the language level works fines as specified in build.gradle file.

But When import Gradle java project into IntelliJ IDEA, Gradle's plugin take responsibility to generate IDEA's project setting files,

Unfortunately, the plug in does not respect build.gradle's sourceCompatibility/targetCompatibility property, instead, it use IDEA's setting: File -> Other Settings -> Default Project Structure -> Project Language Level -> 6 (By default). enter image description here

So, i think this is a bug of gradle's idea plugin. see https://issues.gradle.org/browse/GRADLE-2198

Currently, i have to change language level in above dialog sometimes.