/** * Reads the version of the jar which contains the given class * @param targetClass class within the jar * @return version-string which has been found in the manifest or null if there is no version information available */ public static String getJarVersion(Class targetClass) { String manifestFileLocation = getManifestFileLocationOfClass(targetClass); try { return new Manifest(new URL(manifestFileLocation).openStream()) .getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION); } catch (Exception e) { return null; } }
/** * Reads the VCS revision which was used for creating the jar * @param targetClass class within the jar * @return revision-string which has been found in the manifest or null if there is no information available */ public static String getRevision(Class targetClass) { String manifestFileLocation = getManifestFileLocationOfClass(targetClass); try { return new Manifest(new URL(manifestFileLocation).openStream()) .getMainAttributes().getValue("Revision"); } catch (Exception e) { return null; } }
/** * Reads the VCS revision which was used for creating the jar * @param targetClass class within the jar * @return revision-string which has been found in the manifest or null if there is no information available */ public static String getRevision(Class targetClass) { String manifestFileLocation = getManifestFileLocationOfClass(targetClass); try { return new Manifest(new URL(manifestFileLocation).openStream()) .getMainAttributes().getValue("Revision"); } catch (Exception e) { return null; } }
/** * Reads the version of the jar which contains the given class * @param targetClass class within the jar * @return version-string which has been found in the manifest or null if there is no version information available */ public static String getJarVersion(Class targetClass) { String manifestFileLocation = getManifestFileLocationOfClass(targetClass); try { return new Manifest(new URL(manifestFileLocation).openStream()) .getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION); } catch (Exception e) { return null; } }
/** * Reads the version of the jar which contains the given class * @param targetClass class within the jar * @return version-string which has been found in the manifest or null if there is no version information available */ public static String getJarVersion(Class targetClass) { String manifestFileLocation = getManifestFileLocationOfClass(targetClass); try { return new Manifest(new URL(manifestFileLocation).openStream()) .getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION); } catch (Exception e) { return null; } }
/** * Reads the VCS revision which was used for creating the jar * @param targetClass class within the jar * @return revision-string which has been found in the manifest or null if there is no information available */ public static String getRevision(Class targetClass) { String manifestFileLocation = getManifestFileLocationOfClass(targetClass); try { return new Manifest(new URL(manifestFileLocation).openStream()) .getMainAttributes().getValue("Revision"); } catch (Exception e) { return null; } }