Skip to content

Commit f60925d

Browse files
committed
AbstractApp: improve version detection
Let's use the manifest if available, since it might have the build number. This also adds an explanation for why we don't use VersionUtils.getVersion here.
1 parent 43407c1 commit f60925d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/main/java/org/scijava/app/AbstractApp.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,24 @@ public String getTitle() {
6363

6464
@Override
6565
public String getVersion() {
66-
return getPOM() == null ? "Unknown" : getPOM().getVersion();
66+
// NB: We do not use VersionUtils.getVersion(c, groupId, artifactId)
67+
// because that method does not cache the parsed Manifest and/or POM.
68+
// We might have them already parsed here, and if not, we want to
69+
// parse then cache locally, rather than discarding them afterwards.
70+
71+
// try the manifest first, since it might know its build number
72+
final Manifest m = getManifest();
73+
if (m != null) {
74+
final String v = m.getVersion();
75+
if (v != null) return v;
76+
}
77+
// try the POM
78+
final POM p = getPOM();
79+
if (p != null) {
80+
final String v = p.getVersion();
81+
if (v != null) return v;
82+
}
83+
return "Unknown";
6784
}
6885

6986
@Override

0 commit comments

Comments
 (0)