in plugin-unity-agent/src/main/kotlin/jetbrains/buildServer/unity/detectors/LinuxUnityDetector.kt [41:82]
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
}
LOG.debug("Looking for package manager in $editorRoot")
var version: String? = null
val packageVersions = File(editorRoot, "Editor/Data/PackageManager/Unity/PackageManager")
if (packageVersions.exists()) {
LOG.debug("A package manager was found")
val versions = packageVersions.listFiles { file ->
file.isDirectory
} ?: return null
if (versions.size != 1) {
LOG.warn("Multiple Unity versions found in directory $editorRoot")
}
version = versions.firstOrNull()?.name
} else {
LOG.debug("A package manager was not found")
}
version = version ?: getVersionFromEditor(executable)
if (version == null) {
version = editorRoot.name
}
LOG.info("Version is $version")
return try {
val unityVersion = tryParseVersion(version)
LOG.debug("Reports version $unityVersion to ${editorRoot.name}")
unityVersion
} catch (e: Exception) {
LOG.infoAndDebugDetails("Invalid Unity version $version in directory $editorRoot", e)
null
}
}