简体   繁体   中英

Use Java 7 to compile my project but use Java 8 to run my tests in Gradle

Currently I am deploying my war to a weblogic server that supports java 7 , but would like to take advantage of Java 8 in my selenium and Junit tests .

How would I go about specifying in my Gradle build to use 1.7 to compile and build my WAR while run my tests using 1.8 ?

Split the sources and the tests into 2 modules. Then, specify each module's source&target level:

allprojects {
    sourceCompatibility = 1.7
    targetCompatibility = 1.7
}

Building with JDK1.8 will produce a jar/war for 1.7. Just override this for your test-project and set it to 1.8.

Check this: compiling-a-project-with-different-java-source-compatibility

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM