Do not generate tests tasks for current Java version

This commit is contained in:
Nikolay Martynov 2019-03-25 12:32:36 -04:00
parent 510262d826
commit 75643fe1e9
1 changed files with 13 additions and 2 deletions

View File

@ -152,7 +152,7 @@ if (project.parent && project.parent.hasProperty("javaExecutableVersionCache"))
project.ext.javaExecutableVersionCache = [:] project.ext.javaExecutableVersionCache = [:]
} }
def getJavaExecutableVersion(String path) { JavaVersion getJavaExecutableVersion(String path) {
def cache = project.ext.javaExecutableVersionCache def cache = project.ext.javaExecutableVersionCache
if (cache.containsKey(path)) { if (cache.containsKey(path)) {
@ -221,6 +221,17 @@ for (def env : System.getenv().entrySet()) {
def javaPath = "$javaHome/bin/java" def javaPath = "$javaHome/bin/java"
def javaVersion = getJavaExecutableVersion(javaPath) def javaVersion = getJavaExecutableVersion(javaPath)
// This is slightly complicated because we need to dereference symlinks to make sure
// we are considering same JVM implementation
def currentJavaHome = new File(System.getProperty("java.home")).toPath().toRealPath()
if (currentJavaHome.endsWith("jre")) {
currentJavaHome = currentJavaHome.parent
}
if (currentJavaHome == new File(javaHome).toPath().toRealPath()) {
// Skip JVM implementation we are running gradle on
continue
}
def parentTask = task "testJava${javaName}"() { def parentTask = task "testJava${javaName}"() {
group = 'Verification' group = 'Verification'
description = "Run tests for Java ${javaName}" description = "Run tests for Java ${javaName}"