java.lang.Object
com.atlassian.plugin.osgi.internal.factory.transform.JarUtils

public final class JarUtils extends Object
Utility methods for getting stuff out of a jar.
Since:
2.6
  • Method Details

    • getManifest

      public static Manifest getManifest(File file)
      Get the Manifest from a Jar file, or create a new one if there isn't one already.
      Parameters:
      file - the file that is the jar contents
      Returns:
      the manifest or an empty new one if one can't be found.
    • hasManifestEntry

      public static boolean hasManifestEntry(Manifest manifest, String entryName)
    • withJar

      public static <T> T withJar(File file, JarUtils.Extractor<T> extractor)
      Extract something from a jar file.

      Correctly opens and closes the Jar file. Must not lazily access the Jar as it has an open/closed state.

      Type Parameters:
      T - the type of the thing to extract
      Parameters:
      file - the file that is the jar contents
      extractor - the extractor function to apply
      Returns:
      the result of the extractor
      Throws:
      RuntimeException - if there are problems accessing the jar contents.
    • closeQuietly

      public static void closeQuietly(JarFile jarFile)
      Quietly close jar file.
      Parameters:
      jarFile - the file to close.