Version object that infers its value from the existing Git tags in the repository and the stage and scope of the change.
Version will be inferred by finding the nearest tagged version using NearestVersionLocator. Based on the scope of the changes and the stage of their completion (both of which must be provided to the infer(String, String) method) the nearest version will be incremented appropriately to result in the inferred version.
If the closest tagged version is v1.1.0 (for the normal version) and the closes absolute version is v1.2.0-milestone.1, here are some examples of the versions that would be inferred (assuming the default settings on this object):
| Scope | Stage | Inferred Version |
| patch | milestone | 1.1.1-milestone.1 |
| minor | dev | 1.2.0-dev.<commits since 1.1.0> |
| minor | milestone | 1.2.0-milestone.2 |
| minor | rc | 1.2.0-rc.1 |
| minor | final | 1.2.0 |
| major | milestone | 2.0.0-milestone.1 |
| Modifiers | Name | Description |
|---|---|---|
static enum |
InferredVersion.ChangeScope |
| Type | Name and description |
|---|---|
groovy.lang.Closure<java.lang.Boolean> |
allowReleaseClosure to allow for creating a release under certain conditions. |
groovy.lang.Closure<java.lang.String> |
createBuildMetadataClosure to create the build metadata to use in the inferred versions. |
Grgit |
grgitThe git repository to infer from. |
java.util.SortedSet<java.lang.String> |
taggedStagesValid stages for versions that should have tags created for them. |
java.util.SortedSet<java.lang.String> |
untaggedStagesValid stages for versions that should not have tags created for them. |
groovy.lang.Closure<java.lang.Boolean> |
useBuildMetadataForStageClosure to determine whether build metadata should be included in the inferred version. |
| Constructor and description |
|---|
InferredVersion
(Project project) |
| Type | Name and description |
|---|---|
java.util.SortedSet<java.lang.String> |
getAllStages()Gets all stages considered valid by this object. |
void |
infer()Infers the version using project properties release.scope and
release.stage or falls back to a scope of patch or the
lowest precedence stage from untaggedStages. |
void |
infer(java.lang.String scope, java.lang.String stage)Infers the version using the given arguments. |
void |
infer(InferredVersion.ChangeScope scope, java.lang.String stage)Infers the version using the given arguments. |
java.lang.String |
toString() |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Closure to allow for creating a release under certain conditions.
The typical use case would be to release without any commits during
development. Should return true or false. Defaults to returning true
if there's at least one commit since normal reachable from HEAD.
Closure to create the build metadata to use in the inferred versions. Only exected for stages that meet useBuildMetadataForStage. Will called with no arguments and should return a String representing the build metadata for this version.
The git repository to infer from.
Valid stages for versions that should have tags created for them. These stages will be numbered in incrementing fashion based on the number of the nearest absolute version, if it has the same normal version and stage. Defaults to ['milestone', 'rc'].
Valid stages for versions that should not have tags created for them. These stages will be numbered based on the number of commits since the nearest normal version rather than the number of releases for the inferred normal verison and stage. Defaults to ['dev'].
Closure to determine whether build metadata should be included in the inferred version. Should accept a single String argument for the stage. Should return true or false. Defaults to returning true for stages besides 'final' and false otherwise.
Gets all stages considered valid by this object. Includes all
values from untaggedStages and taggedStages, plus
final.
Infers the version using project properties release.scope and
release.stage or falls back to a scope of patch or the
lowest precedence stage from untaggedStages.
Infers the version using the given arguments.
scope - the scope of the change. Must be a string matching one of
ChangeScope's valuesstage - one of the valid stages for this object. See getAllStages()Infers the version using the given arguments.
scope - the scope of the change.stage - one of the valid stages for this object. See getAllStages()Groovy Documentation