Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle - Different JDK Version for Source and Test

Tags:

java

maven

gradle

How can I configure Gradle to compile test classes for a different Java version than source classes?

I'm writing a project for Java 1.7, and I want to use Java 1.8 in my tests so I can use Lambda Behave. In Maven this is pretty straightforward, but I can't see how to achieve the same result in Gradle.

like image 565
EngineerBetter_DJ Avatar asked Feb 14 '15 08:02

EngineerBetter_DJ


1 Answers

Of course, immediately after posting the question I stumble across the answer!

apply plugin: "java"

compileJava {
    sourceCompatibility = 1.7
}

compileTestJava {
    sourceCompatibility = 1.8
}
like image 136
EngineerBetter_DJ Avatar answered Oct 17 '22 17:10

EngineerBetter_DJ