Skip to content

Commit f576257

Browse files
committed
VersionUtils: add method for class's build number
1 parent 771171b commit f576257

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/main/java/org/scijava/util/VersionUtils.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ public static String getVersionFromPOM(final Class<?> c,
9999
return pom == null ? null : pom.getVersion();
100100
}
101101

102+
/**
103+
* Looks up the build number (typically an SCM revision) of the specified
104+
* class. This information is retrieved from the JAR manifest's
105+
* <code>Implementation-Build</code> entry, or null if no such value exists.
106+
*
107+
* @param c - Look up this class's build number
108+
* @return Build number of specified {@link Class} or null if not found.
109+
*/
110+
public static String getBuildNumber(final Class<?> c) {
111+
return getBuildNumber(Manifest.getManifest(c));
112+
}
113+
102114
// -- Helper methods --
103115

104116
private static String getVersionFromManifest(final Manifest m) {
@@ -107,4 +119,8 @@ private static String getVersionFromManifest(final Manifest m) {
107119
return m.getSpecificationVersion();
108120
}
109121

122+
private static String getBuildNumber(final Manifest m) {
123+
return m == null ? null : m.getImplementationBuild();
124+
}
125+
110126
}

0 commit comments

Comments
 (0)