Groovy Documentation

org.ajoberstar.gradle.git.semver
[Groovy] Class InferredVersion

java.lang.Object
  org.ajoberstar.gradle.git.semver.InferredVersion

class InferredVersion

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):

ScopeStageInferred Version
patchmilestone1.1.1-milestone.1
minordev1.2.0-dev.<commits since 1.1.0>
minormilestone1.2.0-milestone.2
minorrc1.2.0-rc.1
minorfinal1.2.0
majormilestone2.0.0-milestone.1
Since:
0.8.0


Nested Class Summary
static enum InferredVersion.ChangeScope

 
Property Summary
groovy.lang.Closure createBuildMetadata

Closure to create the build metadata to use in the inferred versions.

Grgit grgit

The git repository to infer from.

java.util.SortedSet taggedStages

Valid stages for versions that should have tags created for them.

java.util.SortedSet untaggedStages

Valid stages for versions that should not have tags created for them.

groovy.lang.Closure useBuildMetadataForStage

Closure to determine whether build metadata should be included in the inferred version.

 
Constructor Summary
InferredVersion(Project project)

 
Method Summary
java.util.SortedSet getAllStages()

Gets all stages considered valid by this object.

Version getInferredVersion()

NearestVersion getNearest()

The nearest version that was found in the repository.

boolean getReleasable()

InferredVersion.ChangeScope getScope()

java.lang.String getStage()

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 java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), 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()
 

Property Detail

createBuildMetadata

groovy.lang.Closure createBuildMetadata
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.


grgit

Grgit grgit
The git repository to infer from.


taggedStages

java.util.SortedSet taggedStages
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'].


untaggedStages

java.util.SortedSet untaggedStages
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'].


useBuildMetadataForStage

groovy.lang.Closure useBuildMetadataForStage
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.


 
Constructor Detail

InferredVersion

InferredVersion(Project project)


 
Method Detail

getAllStages

java.util.SortedSet getAllStages()
Gets all stages considered valid by this object. Includes all values from untaggedStages and taggedStages, plus final.
Returns:
all valid stages to be used in infer(java.lang.String, java.lang.String)


getInferredVersion

Version getInferredVersion()


getNearest

NearestVersion getNearest()
The nearest version that was found in the repository.
Returns:
the nearest version


getReleasable

boolean getReleasable()


getScope

InferredVersion.ChangeScope getScope()


getStage

java.lang.String getStage()


infer

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.


infer

void infer(java.lang.String scope, java.lang.String stage)
Infers the version using the given arguments.
Parameters:
scope - the scope of the change. Must be a string matching one of ChangeScope's values
stage - one of the valid stages for this object. See getAllStages()


infer

void infer(InferredVersion.ChangeScope scope, java.lang.String stage)
Infers the version using the given arguments.
Parameters:
scope - the scope of the change.
stage - one of the valid stages for this object. See getAllStages()


toString

@Override
java.lang.String toString()


 

Groovy Documentation