Class VersionTagger
- All Implemented Interfaces:
Generator, Renamable, ResourceProvider
A generator that creates a new Git tag that denotes a Project's
version. The version to be used for the tag is based on
the project's Version property. Together
with the prefix returned by the prefix evaluator, it forms the tag.
The generator reads the property jdbld.versionTagger.mode to
determine how the version for the tag is computed. If the property is not
set, the generator uses the version as-is. If set to one of the algorithm
constants (NEXT_MAJOR, NEXT_MINOR, NEXT_PATCH, CLOSEST_MAJOR,
CLOSEST_MINOR, CLOSEST_PATCH), it increments the respective
version component. The next algorithms always increment, while the
closest algorithms only increment if the version has a pre-release
qualifier (usually SNAPSHOT). Use the -P flag to set the algorithm
on the command line, e.g. jdbld -Pjdbld.versionTagger.mode=nextMinor.
The generator creates annotated tags with a default message of
"Release tag <tag>". You can override this message by setting
property jdbld.versionTagger.message.
The generator uses an instance of Git to access the repository.
If also required elsewhere, the jdbld configuration should associate
the build project with the instance using setGitApi(org.jdrupes.builder.api.RootProject). Else that
property will be set on first usage of the generator.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCreates a new tag that increments the major version if the current version has a pre-release qualifier (e.g.0.3.1-SNAPSHOTbecomes1.0.0).static final StringCreates a new tag that increments the minor version if the current version has a pre-release qualifier (e.g.0.3.1-SNAPSHOTbecomes0.4.0).static final StringCreates a new tag that increments the patch version if the current version has a pre-release qualifier (e.g.0.3.1-SNAPSHOTbecomes0.3.2).static final StringIf defined and not equal tofalseprevents the actual creation of the tag.static final StringDefines the evaluation mode for the new version.static final StringCreates a new tag that increments the major version regardless of any qualifier (e.g.0.3.1becomes1.0.0).static final StringCreates a new tag that increments the minor version regardless of any qualifier (e.g.0.3.1becomes0.4.0).static final StringCreates a new tag that increments the patch version regardless of any qualifier (e.g.0.3.1becomes0.3.2). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <R extends Resource>
Collection<R> doProvide(ResourceRequest<R> requested) Invoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.prefixEvalutor(Function<Project, String> evaluator) Sets the function that determines the prefix for the version tag.preReleaseQualifiers(String... preReleaseQualifier) Sets the pre-release qualifiers.static org.eclipse.jgit.api.GitsetGitApi(RootProject project) Sets the propertyGitProperties.GitApion the root project to an instance ofGit.Methods inherited from class AbstractGenerator
cleanup, name, project, toStringMethods inherited from class AbstractProvider
context, name, of, rename, vavrStreamMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ResourceProvider
context, name, of, resources
-
Field Details
-
DRY_RUN
-
MODE
-
CLOSEST_MAJOR
Creates a new tag that increments the major version if the current version has a pre-release qualifier (e.g.
0.3.1-SNAPSHOTbecomes1.0.0). Does nothing if the version has no snapshot qualifier.Use
jdbld -Pjdbld.versionTagger.mode=closestMajorto set the algorithm.- See Also:
-
CLOSEST_MINOR
Creates a new tag that increments the minor version if the current version has a pre-release qualifier (e.g.
0.3.1-SNAPSHOTbecomes0.4.0). Does nothing if the version has no snapshot qualifier.Use
jdbld -Pjdbld.versionTagger.mode=closestMinorto set the algorithm.- See Also:
-
CLOSEST_PATCH
Creates a new tag that increments the patch version if the current version has a pre-release qualifier (e.g.
0.3.1-SNAPSHOTbecomes0.3.2). Does nothing if the version has no snapshot qualifier.Use
jdbld -Pjdbld.versionTagger.mode=closestPatchto set the algorithm.- See Also:
-
NEXT_MAJOR
Creates a new tag that increments the major version regardless of any qualifier (e.g.
0.3.1becomes1.0.0).Use
jdbld -Pjdbld.versionTagger.mode=nextMajorto set the algorithm.- See Also:
-
NEXT_MINOR
Creates a new tag that increments the minor version regardless of any qualifier (e.g.
0.3.1becomes0.4.0).Use
jdbld -Pjdbld.versionTagger.mode=nextMinorto set the algorithm.- See Also:
-
NEXT_PATCH
Creates a new tag that increments the patch version regardless of any qualifier (e.g.
0.3.1becomes0.3.2).Use
jdbld -Pjdbld.versionTagger.mode=nextPatchto set the algorithm.- See Also:
-
-
Constructor Details
-
VersionTagger
Instantiates a new version reporter.- Parameters:
project- the project
-
-
Method Details
-
setGitApi
Sets the propertyGitProperties.GitApion the root project to an instance ofGit. Does nothing if the property is already set.- Parameters:
project- the new git api- Returns:
- the
Gitinstance
-
preReleaseQualifiers
Sets the pre-release qualifiers. Defaults to"SNAPSHOT".- Parameters:
preReleaseQualifier- the pre release qualifier- Returns:
- the version tagger
-
prefixEvalutor
Sets the function that determines the prefix for the version tag. The tag is formed by concatenating the prefix with the project's version. Defaults to"v".- Parameters:
evaluator- the function that takes a project and returns the prefix string- Returns:
- this generator for chaining
-
doProvide
Description copied from class:AbstractProviderInvoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.- Specified by:
doProvidein classAbstractProvider- Type Parameters:
R- the generic type- Parameters:
requested- the request for resources- Returns:
- the stream
-