How can I build JAVA 7 project using gradle 5.3?

I use sourceCompatibility = 1.7 in and

wrapper {
    gradleVersion = '5.3'
    distributionType = 'ALL'

in build.gradle.

Gradle JVM(Settings, Gradle, Intellij IDEA) is 1.8.0_171

When I run build task(Tasks->build->build Intellij IDEA) I get “error: incompatible types: inferred type does not conform to equality constraint(s)” during compileJava task.

If I set up Gradle JVM is 1.7.0_80 and

wrapper {
gradleVersion = ‘4.3’
distributionType = ‘ALL’

build is fine.

Why is that?

Questions for you:

  1. Why do you have sourceCompatibility = 1.7 in instead of build.gradle? I never knew it was allowed there.
  2. What do you have set in File - Project Structure - Project- Project SDK and Project language level in IntelliJ?
  3. File - Project Structure - Modules - Sources - Language level?