How to set compiler target to Java 8?


I am trying to build which is a bit older as it seems. I opened the project with IntelliJ and tried to used the Gradle integration to build it.
But there’s code that does not work with Java 6, so I get the following message when running the Gradle task “build”:

ArsMagica2/build/sources/java/am2/preloader/ error: diamond operator is not supported in -source 1.6

I already changed the Project SDK and the Project language level to Java 8. I also changed the Module SDK in the project structure settings for modules as well as in the Java Compiler settings in the IntelliJ settings under Build, Execution, Deployment -> Compiler -> Java Compiler. It still uses Java 1.6 as it seems…

edit: I also tried to check the repo out and then simply running ./gradlew build but it results in the same error as above. So I guess I need to set it somewhere in the build.gradle file.

So far I am running out of ideas. I tried to add some configuration to the build.gradle file but I don’t think I got the syntax right.

Do you have any clues how to fix this?

I was finally able to find a combination that works. I use this block:

apply plugin: 'java'
compileJava {
    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'