Previous plugin behaviour didn't allow missing version.properties file nor empty version property in the file. This commit adds a behaviour that allows such configuration and deducts version from tag that code is checked out on.
This functionality is useful for teams that prefer releasing "on demand" and also allows increasing version number as needed, not based on number of commits pushed as in default behaviour with version property set. To use this new simplified behaviour no other configuration option than missing version is needed.
As said implemented feature deducts version based on tag on which a code is checked out. If the tag is valid (has same prefix as configured or default 'v' and version number is valid) deducted version is same as version in tag. If other tags that are valid are found, previousVersion which is exposed by the plugin, is a version with highest number less than deducted version (eg. for tag v1.1.5 plugin deducts version number 1.1.5 and assuming that tag v1.1.4 exists, exposed previousVersion is 1.1.4). If code is not checked out on a valid tag and version is not set as property the plugin deducts version 0.0.1.
To implement this behaviour getter for requestedVersion() in 'VersionConfig class was added, and it returns Optional, which is tested in NextVersionPicker and PreviousVersionFinder classes for containing a value, and further logic in these classes is based upon this check for requestedVersion. Also deductVersion() method in AutoVersion checks if requestedVersion is found in configuration, and if not previousVersion is being found using newly deducted version which is passed as argument to findPreviousVersion().
New behaviour is tested by two new unit tests in NextVersionPickerTest, two tests ("no file" and "missing version property") refactored in VersionConfigTest and was also tested manually by building test project with various configuration options.
Previous plugin behaviour didn't allow missing
version.properties
file nor emptyversion
property in the file. This commit adds a behaviour that allows such configuration and deducts version from tag that code is checked out on. This functionality is useful for teams that prefer releasing "on demand" and also allows increasing version number as needed, not based on number of commits pushed as in default behaviour withversion
property set. To use this new simplified behaviour no other configuration option than missingversion
is needed.As said implemented feature deducts version based on tag on which a code is checked out. If the tag is valid (has same prefix as configured or default 'v' and version number is valid) deducted version is same as version in tag. If other tags that are valid are found,
previousVersion
which is exposed by the plugin, is a version with highest number less than deducted version (eg. for tagv1.1.5
plugin deducts version number1.1.5
and assuming that tagv1.1.4
exists, exposedpreviousVersion
is1.1.4
). If code is not checked out on a valid tag andversion
is not set as property the plugin deducts version0.0.1
.To implement this behaviour getter for
requestedVersion()
in'VersionConfig
class was added, and it returns Optional, which is tested inNextVersionPicker
andPreviousVersionFinder
classes for containing a value, and further logic in these classes is based upon this check forrequestedVersion
. AlsodeductVersion()
method inAutoVersion
checks ifrequestedVersion
is found in configuration, and if notpreviousVersion
is being found using newly deducted version which is passed as argument tofindPreviousVersion()
. New behaviour is tested by two new unit tests inNextVersionPickerTest
, two tests ("no file" and "missing version property") refactored inVersionConfigTest
and was also tested manually by building test project with various configuration options.This PR resolves #1