public class GitVersionCalculatorImpl extends Object implements GitVersionCalculator
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
String |
getVersion()
Return the version to use for the current git repository depending on the HEAD position.
|
String |
getVersion(boolean forceComputation)
Calculates if necessary the version to use for the current git repository depending on the HEAD position.
|
Version |
getVersionObject()
Return the version to use for the current git repository depending on the HEAD position.
|
Version |
getVersionObject(boolean forceComputation)
Calculates the version to use for the current git repository depending on the HEAD position.
|
Optional<String> |
meta(Metadatas meta) |
GitVersionCalculator |
setAutoIncrementPatch(boolean value)
When true, when the found tag to calculate a version for HEAD is a normal/annotated one, the semver patch version
of the tag is increased by one ; except when the tag is on the HEAD itself.
|
GitVersionCalculator |
setFindTagVersionPattern(String pattern)
Defines a regexp search pattern that will match tags identifying a version.
|
GitVersionCalculator |
setForceComputation(boolean forceComputation)
When true, force the computation of the version even if HEAD is on a version tag.
|
GitVersionCalculator |
setGitCommitIdLength(int gitCommitIdLength)
Defines how long the qualifier from SHA1 git commit has to be.
|
GitVersionCalculator |
setLookupPolicy(LookupPolicy policy)
Defines the
LookupPolicy to be used for the next version resolution. |
GitVersionCalculator |
setMavenLike(boolean mavenLike)
Activates the maven like mode.
|
GitVersionCalculator |
setMaxDepth(int maxDepth)
Defines max depth to look for version tags, defaults to Integer.MAX_VALUE.
|
GitVersionCalculator |
setNonQualifierBranches(String nonQualifierBranches)
Defines a comma separated list of branches for which no branch name qualifier will be used. default "master".
|
GitVersionCalculator |
setQualifierBranchingPolicies(BranchingPolicy... policies)
Sets as an array the policies that will be applied to try to build a qualifier from the branch of the HEAD.
|
GitVersionCalculator |
setQualifierBranchingPolicies(List<BranchingPolicy> policies)
Sets as a list the policies that will be applied to try to build a qualifier from the branch of the HEAD.
|
GitVersionCalculator |
setScript(String script)
Set the script to be interpreted.
|
GitVersionCalculator |
setScriptType(ScriptType scriptType)
Set the type of the script (default:
ScriptType.GROOVY). |
GitVersionCalculator |
setStrategy(Strategies s)
Defines the strategy to use.
|
GitVersionCalculator |
setTagVersionPattern(String pattern)
Defines the version pattern to use in
Strategies.PATTERN mode when HEAD is on an annotated tag |
GitVersionCalculator |
setUseDefaultBranchingPolicy(boolean useDefaultBranchingPolicy)
When true, uses
BranchingPolicy.DEFAULT_FALLBACK as last BranchingPolicy. |
GitVersionCalculator |
setUseDirty(boolean useDirty)
When true, append a qualifier with the "dirty" qualifier if the repository is in a dirty state (ie with
uncommited changes or new files)
|
GitVersionCalculator |
setUseDistance(boolean useDistance)
When true, append a qualifier with the distance between the HEAD commit and the found commit with a version tag.
|
GitVersionCalculator |
setUseGitCommitId(boolean useGitCommitId)
When true, append the git commit id (SHA1) to the version.
|
GitVersionCalculator |
setUseGitCommitTimestamp(boolean useGitCommitTimestamp)
When true, append the git commit timestamp to the version.
|
GitVersionCalculator |
setUseLongFormat(boolean useLongFormat)
When true describes commits hash with long format pattern, ie preceded with the letter 'g'.
|
GitVersionCalculator |
setUseSnapshot(boolean useSnapshot)
When true, append a qualifier with the "SNAPSHOT" qualifier if no version tags found.
|
GitVersionCalculator |
setVersionPattern(String pattern)
Defines the version pattern to use in
Strategies.PATTERN mode for normal situation (i.e. not on a tag) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitlocationpublic Version getVersionObject(boolean forceComputation)
GitVersionCalculatorgetVersionObject in interface GitVersionCalculatorforceComputation - true to discard any previous cached result, false allow to reuse already cached valuespublic Version getVersionObject()
GitVersionCalculatorgetVersionObject in interface GitVersionCalculatorpublic String getVersion()
GitVersionCalculatorgetVersion in interface GitVersionCalculatorpublic String getVersion(boolean forceComputation)
GitVersionCalculatorgetVersion in interface GitVersionCalculatorforceComputation - true to force computation even if no computation parameters have changed,
false to allow to retrieve the value from the last computed version.public void close()
throws Exception
close in interface GitVersionCalculatorclose in interface AutoCloseableExceptionpublic GitVersionCalculator setAutoIncrementPatch(boolean value)
GitVersionCalculatorsetAutoIncrementPatch in interface GitVersionCalculatorvalue - if true and when found tag is not on HEAD, then version returned will be the found version with
patch number increased by one. default false.public GitVersionCalculator setNonQualifierBranches(String nonQualifierBranches)
GitVersionCalculatorGitVersionCalculator.setQualifierBranchingPolicies(List) &
GitVersionCalculator.setQualifierBranchingPolicies(BranchingPolicy...).setNonQualifierBranches in interface GitVersionCalculatornonQualifierBranches - a comma separated list of branch name for which no branch name qualifier should be
used, can be null and/or emptypublic GitVersionCalculator setQualifierBranchingPolicies(BranchingPolicy... policies)
GitVersionCalculatorGitVersionCalculator.setNonQualifierBranches(String) & GitVersionCalculator.setQualifierBranchingPolicies(List).setQualifierBranchingPolicies in interface GitVersionCalculatorpolicies - an array of policies to apply can be emptypublic GitVersionCalculator setQualifierBranchingPolicies(List<BranchingPolicy> policies)
GitVersionCalculatorGitVersionCalculator.setNonQualifierBranches(String) &
GitVersionCalculator.setQualifierBranchingPolicies(BranchingPolicy...).setQualifierBranchingPolicies in interface GitVersionCalculatorpolicies - an array of policies to apply can be emptypublic GitVersionCalculator setUseDistance(boolean useDistance)
GitVersionCalculatorsetUseDistance in interface GitVersionCalculatoruseDistance - if true, a qualifier with found distance will be used.public GitVersionCalculator setUseDirty(boolean useDirty)
GitVersionCalculatorsetUseDirty in interface GitVersionCalculatoruseDirty - if true, a qualifier with "dirty" qualifier will be used if the repository is stall.public GitVersionCalculator setUseLongFormat(boolean useLongFormat)
GitVersionCalculatorsetUseLongFormat in interface GitVersionCalculatoruseLongFormat - if true and useGitCommitId,
then commitId will be prepended with a 'g' to be compliant with `git describe --long` formatpublic GitVersionCalculator setUseGitCommitId(boolean useGitCommitId)
GitVersionCalculatorsetUseGitCommitId in interface GitVersionCalculatoruseGitCommitId - if true, a qualifier with SHA1 git commit will be used, default truepublic GitVersionCalculator setUseGitCommitTimestamp(boolean useGitCommitTimestamp)
GitVersionCalculatorsetUseGitCommitTimestamp in interface GitVersionCalculatoruseGitCommitTimestamp - if true, a qualifier with git commit timestamp will be used, default falsepublic GitVersionCalculator setUseDefaultBranchingPolicy(boolean useDefaultBranchingPolicy)
GitVersionCalculatorBranchingPolicy.DEFAULT_FALLBACK as last BranchingPolicy.setUseDefaultBranchingPolicy in interface GitVersionCalculatoruseDefaultBranchingPolicy - if true, appends BranchingPolicy.DEFAULT_FALLBACK as last branching policypublic GitVersionCalculator setGitCommitIdLength(int gitCommitIdLength)
GitVersionCalculatorsetGitCommitIdLength in interface GitVersionCalculatorgitCommitIdLength - the length of the SHA1 substring to use as qualifier, valid values [8, 40], default 8public GitVersionCalculator setMavenLike(boolean mavenLike)
GitVersionCalculatorsetMavenLike in interface GitVersionCalculatormavenLike - true to activate maven like modepublic GitVersionCalculator setFindTagVersionPattern(String pattern)
GitVersionCalculatorsetFindTagVersionPattern in interface GitVersionCalculatorpattern - a non null string representing a java regexp pattern able to match tag containing versionspublic Optional<String> meta(Metadatas meta)
meta in interface GitVersionCalculatormeta in interface MetadataProviderpublic GitVersionCalculator setStrategy(Strategies s)
GitVersionCalculatorsetStrategy in interface GitVersionCalculators - the non null strategy to use as a Strategies enum valuepublic GitVersionCalculator setTagVersionPattern(String pattern)
GitVersionCalculatorStrategies.PATTERN mode when HEAD is on an annotated tagsetTagVersionPattern in interface GitVersionCalculatorpattern - the pattern to use for annotated tagspublic GitVersionCalculator setVersionPattern(String pattern)
GitVersionCalculatorStrategies.PATTERN mode for normal situation (i.e. not on a tag)setVersionPattern in interface GitVersionCalculatorpattern - the pattern to usepublic GitVersionCalculator setMaxDepth(int maxDepth)
GitVersionCalculatorsetMaxDepth in interface GitVersionCalculatormaxDepth - the maximum depth to reach to lookup for version tagspublic GitVersionCalculator setLookupPolicy(LookupPolicy policy)
GitVersionCalculatorLookupPolicy to be used for the next version resolution.setLookupPolicy in interface GitVersionCalculatorpolicy - the policy kind, cannot be nullpublic GitVersionCalculator setUseSnapshot(boolean useSnapshot)
GitVersionCalculatorsetUseSnapshot in interface GitVersionCalculatoruseSnapshot - if true, a qualifier with "SNAPSHOT" qualifier if no version tags found.public GitVersionCalculator setForceComputation(boolean forceComputation)
GitVersionCalculatorsetForceComputation in interface GitVersionCalculatorforceComputation - if true, forces the computation of version using other defined parameterspublic GitVersionCalculator setScriptType(ScriptType scriptType)
GitVersionCalculatorScriptType.GROOVY).setScriptType in interface GitVersionCalculatorscriptType - the script typepublic GitVersionCalculator setScript(String script)
GitVersionCalculatorsetScript in interface GitVersionCalculatorscript - the script contentCopyright © 2016–2021 Matthieu Brouillard. All rights reserved.