All Downloads are FREE. Search and download functionalities are using the official Maven repository.

godot.gradle.tasks.graal.ios.IOSJavaVersion.kt Maven / Gradle / Ivy

There is a newer version: 0.11.0-4.3
Show newest version
package godot.gradle.tasks.graal.ios

import godot.gradle.projectExt.godotJvmExtension
import org.gradle.api.Project

enum class IOSJavaVersion {
    JVM_11,
    JVM_17;

    companion object {
        operator fun invoke(project: Project): IOSJavaVersion {
            val javaCPath = project.godotJvmExtension.graalVmDirectory
                .get()
                .asFile
                .resolve("bin")
                .resolve("javac")
                .absolutePath
            val javaVersionProcess = ProcessBuilder(
                javaCPath,
                "-version"
            ).start()

            require(javaVersionProcess.waitFor() == 0) {
                buildString {
                    appendLine("Can't find graalvm home, please set your graalvm home to")
                    appendLine(javaVersionProcess.errorStream.readAllBytes().decodeToString())
                }
            }

            return if (javaVersionProcess.inputStream.readAllBytes().decodeToString().startsWith("javac 17")) {
                JVM_17
            } else {
                JVM_11
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy