override fun getVersionFromInstall()

in plugin-unity-agent/src/main/kotlin/jetbrains/buildServer/unity/detectors/MacOsUnityDetector.kt [30:55]


    override fun getVersionFromInstall(editorRoot: File): UnityVersion? {
        LOG.debug("Looking for Unity installation in $editorRoot")
        val executable = getEditorPath(editorRoot)
        if (!executable.exists()) {
            LOG.debug("Cannot find $executable")
            return null
        }

        val plistFile = File(editorRoot, "Unity.app/Contents/Info.plist")
        if (!plistFile.exists()) {
            LOG.debug("Cannot find $plistFile")
            return null
        }

        val version = XMLPropertyListConfiguration().let {
            FileHandler(it).load(plistFile)
            it.getString("CFBundleVersion")
        }

        return try {
            tryParseVersion(version)
        } catch (e: Exception) {
            LOG.infoAndDebugDetails("Invalid Unity version $version in directory $editorRoot", e)
            null
        }
    }