def extractInstalledPluginDescriptorFileContent()

in ideaSupport/src/main/scala/org/jetbrains/sbtidea/download/plugin/LocalPluginRegistry.scala [105:127]


  def extractInstalledPluginDescriptorFileContent(pluginRoot: Path): Either[String, PluginXmlContent] =
    extractInstalledPluginDescriptorFileContent(pluginRoot, "plugin.xml")

  private def extractInstalledPluginDescriptorFileContent(pluginRoot: Path, pluginXmlFileName: String): Either[String, PluginXmlContent] = {
    def couldNotFindPluginXml = s"Couldn't find $pluginXmlFileName in $pluginRoot"

    try {
      val pluginXmlDetector = new PluginXmlDetector(pluginXmlFileName)

      if (Files.isDirectory(pluginRoot)) {
        val lib = pluginRoot.resolve("lib")
        if (lib.toFile.exists())
          pluginXmlDetector.findPluginXmlContentInDir(lib).toRight(couldNotFindPluginXml)
        else
          Left(s"Plugin root $pluginRoot has no lib directory")
      } else
        pluginXmlDetector.pluginXmlContent(pluginRoot).toRight(couldNotFindPluginXml)
    }
    catch {
      case e: Exception =>
        Left(s"Error during detecting plugin.xml: $e")
    }
  }