Class Version
JMRI version strings are of the form x.y.z-m:
- x, called the "major" number, is a small integer that increases with time
- y, called the "minor" number, is a small integer that increases with time
- z, called the "test" or "build" number, is a small integer increasing with time, perhaps followed by a couple of modifier characters. As a special case, this is omitted for Production Releases.
- m, called the modifier, is a string that further describes the build. A common modifier is "plus" which denotes an unofficial build.
The version string shown by a JMRI program or used to label a download comes in two forms, depending on whether it was built by an "official" process or not, which in turn is determined by the "release.official" property:
- Official
-
- If the revision number e.g. 123abc (git hash) is available in release.revision_id, then "4.1.1+R123abc". Note the "R".
- Else "4.1.1+(date)", where the date comes from the release.build_date property.
- Unofficial
-
Unofficial releases are marked by "plus" after the version number, and
inclusion of the building user's ID.
- If the revision number e.g. 123abc (git hash) is available in release.revision_id, then "4.1.1plus+(user)+(date)+R123abc". Note the "R".
- Else "4.1.1+(user)+(date)", where the date comes from the release.build_date property.
Generally, JMRI updates its version string in the code repository right after a release. Between formal release 1.2.3 and 1.2.4, the string will be 1.2.4plus.
This file is part of JMRI.
JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.
JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe date/time of this build.static final StringThe user who built this versionBundle, as determined by the build machine.static final intMajor number changes with large incompatible changes in requirements or API.static final intMinor number changes with each production versionBundle.static final StringThe additional MODIFIER for the release.static final StringDescriptor for non-official build.static final booleanHas this build been created as a possible "official" versionBundle?static final StringThe Git revision ID for this versionBundle (if known).static final intTest number changes with individual releases, generally fastest for test releases. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcompareCanonicalVersions(String version) Compares a canonical version string to the JMRI canonical version and returns an integer indicating if the string is less than, equal to, or greater than the JMRI canonical version.static intcompareCanonicalVersions(String version1, String version2) Compares two canonical version strings and returns an integer indicating if the first string is less than, equal to, or greater than the second string.static StringReturn the version as major.minor.test-modifiers.static StringReturn the application copyright as a String.static StringGet the MODIFIER in the 1.2.3-MODIFIER version name.static booleanisCanonicalVersion(String version) Tests that a string contains a canonical version string.static voidStandalone print of version string and exit.static Stringname()Provide the current version string.
-
Field Details
-
major
Major number changes with large incompatible changes in requirements or API. -
minor
Minor number changes with each production versionBundle. Odd is development, even is production. -
test
Test number changes with individual releases, generally fastest for test releases. In production releases, if non-zero, indicates a bug fix only release. -
MODIFIER
The additional MODIFIER for the release. Used to indicate a parallel release of a feature that has not been accepted into main stream development. -
NON_OFFICIAL
Descriptor for non-official build. Included inname(), but not ingetCanonicalVersion().- See Also:
-
buildUser
The user who built this versionBundle, as determined by the build machine. -
revisionId
The Git revision ID for this versionBundle (if known). -
buildDate
The date/time of this build. -
official
Has this build been created as a possible "official" versionBundle?
-
-
Constructor Details
-
Version
public Version()
-
-
Method Details
-
getModifier
Get the MODIFIER in the 1.2.3-MODIFIER version name. Non-official versions include "plus" in the MODIFIER.- Returns:
- the third term, possibly an empty String if
testis 0
-
name
Provide the current version string.This string is built using various known build parameters, including the versionBundle.{major,minor,build} values, the MODIFIER, the Git revision ID (if known) and the official property
- Returns:
- The current version string
-
isCanonicalVersion
Tests that a string contains a canonical version string.A canonical version string is a string in the form x.y.z[-a[-b[-...]]] where parts x, y, and z are integers and parts a, b, ... are free-form text and is different than the version string displayed using
name(). The canonical version string for a JMRI instance is available usinggetCanonicalVersion(). The canonical version will not include official indicators or build metadata.- Parameters:
version- version string to check- Returns:
- true if version is a canonical version string
-
compareCanonicalVersions
Compares a canonical version string to the JMRI canonical version and returns an integer indicating if the string is less than, equal to, or greater than the JMRI canonical version.- Parameters:
version- version string to compare- Returns:
- -1, 0, or 1 if version is less than, equal to, or greater than JMRI canonical version
- Throws:
IllegalArgumentException- if version is not a canonical version string- See Also:
-
compareCanonicalVersions
public static int compareCanonicalVersions(String version1, String version2) throws IllegalArgumentException Compares two canonical version strings and returns an integer indicating if the first string is less than, equal to, or greater than the second string. This comparison ignores modifiers.- Parameters:
version1- a canonical version stringversion2- a canonical version string- Returns:
- -1, 0, or 1 if version1 is less than, equal to, or greater than version2
- Throws:
IllegalArgumentException- if either version string is not a canonical version string- See Also:
-
getCanonicalVersion
Return the version as major.minor.test-modifiers. The test value is always present. The "plus" modifier is not present in the canonical version.- Returns:
- the canonical version
-
getCopyright
Return the application copyright as a String.- Returns:
- the copyright
-
main
Standalone print of version string and exit. This is used in the build.xml to generate parts of the installer versionBundle file name, so take care in altering this code to make sure the ant recipes are also suitably modified.- Parameters:
args- command-line arguments
-