if(is == null) {
// Failed to determine the bot version
Out.fatalException(new FileNotFoundException(vpPath));
}
Properties versionprops = new SortedProperties();
versionprops.load(is);
is.close();
Integer VER_SVN_REVISION_FILE = null;
if(versionprops.containsKey(sReleaseType))
RELEASE_TYPE = ReleaseType.valueOf((String)versionprops.get(sReleaseType));
if(versionprops.containsKey(sVerMajor))
VER_MAJOR = Integer.parseInt((String)versionprops.get(sVerMajor));
if(versionprops.containsKey(sVerMinor))
VER_MINOR = Integer.parseInt((String)versionprops.get(sVerMinor));
if(versionprops.containsKey(sVerRevision))
VER_REVISION = Integer.parseInt((String)versionprops.get(sVerRevision));
if(versionprops.containsKey(sVerRelease))
VER_RELEASE = Integer.parseInt((String)versionprops.get(sVerRelease));
if(versionprops.containsKey(sVerSVNRevision))
VER_SVN_REVISION_FILE = Integer.parseInt((String)versionprops.get(sVerSVNRevision));
// From a JAR has no src folder; from Eclipse has no JAR
if(fromJar != (revision() == null))
throw new IllegalStateException();
if(fromJar) {
BUILD_DATE = new Date(Long.parseLong(versionprops.getProperty(sBuildDate)));
VER_SVN_REVISION = VER_SVN_REVISION_FILE;
} else {
BUILD_DATE = new Date();
versionprops.setProperty(sBuildDate, Long.toString(BUILD_DATE.getTime()));
if((VER_SVN_REVISION_FILE == null) || (VER_SVN_REVISION > VER_SVN_REVISION_FILE)) {
Out.info(CurrentVersion.class, "File version (" + VER_SVN_REVISION_FILE + ") does not match calculated (" + VER_SVN_REVISION + ").");
RELEASE_TYPE = ReleaseType.Development;
versionprops.setProperty(sReleaseType, RELEASE_TYPE.name());
versionprops.setProperty(sVerSVNRevision, Integer.toString(VER_SVN_REVISION));
}
}
VER = new VersionNumber(RELEASE_TYPE, VER_MAJOR, VER_MINOR, VER_REVISION, VER_RELEASE, VER_SVN_REVISION, BUILD_DATE);
if(!fromJar)
versionprops.store(new FileOutputStream(f), VER.toString());
return VER;
} catch(Exception e) {
Out.exception(e);
throw new IllegalStateException(e.getMessage(), e);
}