as32: Improve plugin update verification messages
This commit is contained in:
committed by
Nikolay Krasko
parent
6523d4e306
commit
855c0a353c
+2
-1
@@ -159,7 +159,8 @@ class KotlinUpdatesSettingsConfigurable : SearchableConfigurable, Configurable.N
|
|||||||
|
|
||||||
is PluginUpdateStatus.Unverified -> {
|
is PluginUpdateStatus.Unverified -> {
|
||||||
val version = pluginUpdateStatus.updateStatus.pluginDescriptor.version
|
val version = pluginUpdateStatus.updateStatus.pluginDescriptor.version
|
||||||
form.setUpdateStatus("A new version $version is found, but not yet verified by Android Studio: ${pluginUpdateStatus.message}", false)
|
val message = "<html>A new version $version is found, but unverified:<br/> ${pluginUpdateStatus.message}</html>"
|
||||||
|
form.setUpdateStatus(message, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,11 @@ import java.net.URL
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.xml.bind.JAXBContext
|
import javax.xml.bind.JAXBContext
|
||||||
import javax.xml.bind.annotation.*
|
import javax.xml.bind.annotation.*
|
||||||
import kotlin.collections.HashSet
|
|
||||||
import com.intellij.ide.plugins.PluginNode
|
import com.intellij.ide.plugins.PluginNode
|
||||||
|
import com.intellij.openapi.diagnostic.Logger
|
||||||
|
import java.io.IOException
|
||||||
|
import java.net.MalformedURLException
|
||||||
|
import javax.xml.bind.JAXBException
|
||||||
|
|
||||||
class GooglePluginUpdateVerifier : PluginUpdateVerifier() {
|
class GooglePluginUpdateVerifier : PluginUpdateVerifier() {
|
||||||
|
|
||||||
@@ -24,6 +27,7 @@ class GooglePluginUpdateVerifier : PluginUpdateVerifier() {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val version = pluginDescriptor.version
|
||||||
try {
|
try {
|
||||||
val url = URL(METADATA_FILE_URL)
|
val url = URL(METADATA_FILE_URL)
|
||||||
val stream = url.openStream()
|
val stream = url.openStream()
|
||||||
@@ -32,16 +36,16 @@ class GooglePluginUpdateVerifier : PluginUpdateVerifier() {
|
|||||||
val pluginCompatibility = unmarshaller.unmarshal(stream) as PluginCompatibility
|
val pluginCompatibility = unmarshaller.unmarshal(stream) as PluginCompatibility
|
||||||
|
|
||||||
val release = getRelease(pluginCompatibility) ?: return PluginVerifyResult.decline("no verified versions for this build")
|
val release = getRelease(pluginCompatibility) ?: return PluginVerifyResult.decline("no verified versions for this build")
|
||||||
val version = pluginDescriptor.version
|
return if (release.plugins().any { KOTLIN_PLUGIN_ID == it.id && version == it.version }) PluginVerifyResult.accept()
|
||||||
if (release.plugins().any { version == it.version }) {
|
else PluginVerifyResult.decline("version to be verified")
|
||||||
return PluginVerifyResult.accept()
|
|
||||||
} else {
|
|
||||||
return PluginVerifyResult.decline("version to be verified")
|
|
||||||
}
|
|
||||||
} catch (e : Exception) {
|
} catch (e : Exception) {
|
||||||
val reason = String.format("Failed to verify plugin %s version %s due to exception %s",
|
LOG.error("Exception when verifying plugin ${pluginDescriptor.pluginId.idString} version $version", e)
|
||||||
pluginDescriptor.name, pluginDescriptor.version, e.message)
|
return when (e) {
|
||||||
return PluginVerifyResult.decline(reason)
|
is MalformedURLException, is IOException ->
|
||||||
|
PluginVerifyResult.decline("unable to connect to compatibility verification repository")
|
||||||
|
is JAXBException -> PluginVerifyResult.decline("unable to parse compatibility verification metadata")
|
||||||
|
else -> PluginVerifyResult.decline("exception during verification ${e.message}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,8 +68,9 @@ class GooglePluginUpdateVerifier : PluginUpdateVerifier() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val KOTLIN_PLUGIN_ID = "org.jetbrains.kotlin"
|
private const val KOTLIN_PLUGIN_ID = "org.jetbrains.kotlin"
|
||||||
private const val METADATA_FILE_URL =
|
private const val METADATA_FILE_URL = "https://dl.google.com/android/studio/plugins/compatibility.xml"
|
||||||
"https://dl.google.com/android/studio/plugins/compatibility.xml"
|
|
||||||
|
private val LOG = Logger.getInstance(GooglePluginUpdateVerifier::class.java)
|
||||||
|
|
||||||
private fun PluginCompatibility.releases() = studioRelease ?: emptyArray()
|
private fun PluginCompatibility.releases() = studioRelease ?: emptyArray()
|
||||||
private fun StudioRelease.plugins() = ideaPlugin ?: emptyArray()
|
private fun StudioRelease.plugins() = ideaPlugin ?: emptyArray()
|
||||||
|
|||||||
Reference in New Issue
Block a user