Browse Source
Previously, we were setting kotlin.jvmTarget version to 1.8 if it was null or < 1.8. As an unintended consequence we were also overriding a version set by the jvmToolchain property. So while users expected the jvmToolchain property to set both jdk home & jdk target, we were quietly overriding jdk target. At the same time, Kotlin 1.7 sets the minimum target version to 1.8 anyway, so our override does not make sense with Kotlin 1.7+. This commit removes overriding altogether. Fixes #2511release/1.2.2
Alexey Tsvetkov
2 years ago
committed by
Igor Demin
8 changed files with 56 additions and 20 deletions
@ -0,0 +1,31 @@
|
||||
/* |
||||
* Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. |
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. |
||||
*/ |
||||
|
||||
package org.jetbrains.compose.test.utils |
||||
|
||||
import java.io.File |
||||
|
||||
const val JDK_11_BYTECODE_VERSION = 55 |
||||
|
||||
fun readClassFileVersion(classFile: File): Int { |
||||
val url = classFile.toURI().toURL().toExternalForm() |
||||
val javapResult = runJavaTool("javap", "-verbose", url) |
||||
val majorVersionRegex = "major version: (\\d+)".toRegex() |
||||
val bytecode = javapResult.out |
||||
val match = majorVersionRegex.find(bytecode) |
||||
?: error(buildString { |
||||
appendLine("Could not find 'major version' in '$classFile' bytecode:") |
||||
appendLine(bytecode) |
||||
}) |
||||
return match.groupValues[1].toInt() |
||||
} |
||||
|
||||
fun runJavaTool(toolName: String, vararg args: String): ProcessRunResult { |
||||
val javaHome = File(System.getProperty("java.home")) |
||||
val toolExecutableName = if (isWindows) "$toolName.exe" else toolName |
||||
val executable = javaHome.resolve("bin/$toolExecutableName") |
||||
check(executable.isFile) { "Could not find tool '$toolName' at specified path: $executable" } |
||||
return runProcess(executable, args.toList()) |
||||
} |
Loading…
Reference in new issue