All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.backuity.puppet.VersionUtil.scala Maven / Gradle / Ivy

There is a newer version: 2.2.1
Show newest version
package org.backuity.puppet

import java.net.URL
import java.util.jar.Manifest

object VersionUtil {

  private def toManifest(url: URL) : Manifest = {
    new Manifest(url.openStream())
  }

  def versionFor(projectName : String) : Option[String] = {
    import scala.collection.JavaConversions._
    val manifests: List[URL] = this.getClass.getClassLoader.getResources("META-INF/MANIFEST.MF").toList
    manifests.map(toManifest).find( _.getMainAttributes.getValue("Implementation-Title") == projectName)
        .map( _.getMainAttributes.getValue("Implementation-Version"))
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy