def pluginXmlContent()

in ideaSupport/src/main/scala/org/jetbrains/sbtidea/download/PluginXmlDetector.scala [24:43]


  def pluginXmlContent(path: Path): Option[PluginXmlContent] = {
    val isJarFile = path.toString.endsWith(".jar")
    if (!isJarFile)
      return None

    val uri = URI.create(s"jar:${path.toUri}")

    try
      Using.resource(FileSystems.newFileSystem(uri, EmptyEnvVars)) { fs =>
        val maybePluginXmlPath = Some(fs.getPath("META-INF", pluginXmlFileName)).filter(Files.exists(_))
        maybePluginXmlPath.map { path =>
          val content = new String(Files.readAllBytes(path))
          PluginXmlContent(path, content)
        }
      }
    catch {
      case e: java.util.zip.ZipError =>
        throw new RuntimeException(s"Corrupt zip file: $path", e)
    }
  }