@@ -152,7 +152,7 @@ if (project.parent && project.parent.hasProperty("javaExecutableVersionCache"))
152
152
project. ext. javaExecutableVersionCache = [:]
153
153
}
154
154
155
- def getJavaExecutableVersion (String path ) {
155
+ JavaVersion getJavaExecutableVersion (String path ) {
156
156
def cache = project. ext. javaExecutableVersionCache
157
157
158
158
if (cache. containsKey(path)) {
@@ -221,14 +221,25 @@ for (def env : System.getenv().entrySet()) {
221
221
def javaPath = " $javaHome /bin/java"
222
222
def javaVersion = getJavaExecutableVersion(javaPath)
223
223
224
+ // This is slightly complicated because we need to dereference symlinks to make sure
225
+ // we are considering same JVM implementation
226
+ def currentJavaHome = new File (System . getProperty(" java.home" )). toPath(). toRealPath()
227
+ if (currentJavaHome. endsWith(" jre" )) {
228
+ currentJavaHome = currentJavaHome. parent
229
+ }
230
+ if (currentJavaHome == new File (javaHome). toPath(). toRealPath()) {
231
+ // Skip JVM implementation we are running gradle on
232
+ continue
233
+ }
234
+
224
235
def parentTask = task " testJava${ javaName} " () {
225
236
group = ' Verification'
226
237
description = " Run tests for Java ${ javaName} "
227
238
}
228
239
tasks. check. dependsOn parentTask
229
240
230
241
tasks. withType(Test ). configureEach {
231
- // if (name.endsWith("Generated")) {
242
+ // if (name.endsWith("Generated")) {
232
243
if (! name. equals(" test" )) {
233
244
// The way we're copying the test doesn't currently work with "test-sets" generated tests.
234
245
return
0 commit comments