Class JarUtils
java.lang.Object
com.atlassian.plugin.osgi.internal.factory.transform.JarUtils
Utility methods for getting stuff out of a jar.
- Since:
- 2.6
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloseQuietly(JarFile jarFile) Quietly close jar file.static ManifestgetManifest(File file) Get theManifestfrom a Jar file, or create a new one if there isn't one already.static booleanhasManifestEntry(Manifest manifest, String entryName) static <T> TwithJar(File file, JarUtils.Extractor<T> extractor) Extract something from a jar file.
-
Method Details
-
getManifest
Get theManifestfrom 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
-
withJar
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 contentsextractor- the extractor function to apply- Returns:
- the result of the extractor
- Throws:
RuntimeException- if there are problems accessing the jar contents.
-
closeQuietly
Quietly close jar file.- Parameters:
jarFile- the file to close.
-