maven-git-versioning-extension
maven-git-versioning-extension copied to clipboard
describeTagPattern-Example in docs suggests behaviour not actually implemented
The readme has an example showing how to build a version from describe tag pattern groups:
<ref type="branch">
<pattern>main</pattern>
<describeTagPattern><![CDATA[v(?<version>.*)]]></describeTagPattern>
<version>${describe.tag.version}-SNAPSHOT</version>
</ref>
This looks like as if the placeholder describe.tag.version contains the text matched by the regex in <describeTagPattern>, but actually the placeholder contains the version as matched by the fixed regex that is used to generate describe.tag.version.*placeholders.
This is because the method generateGlobalPlaceholdersMap() first adds the groups created by the describeTagPattern to the placeholders map and than adds the describe.tag.version.*placeholders which results in description.tag.version being overwritten:
for (String groupName : patternGroups(gitSituation.getDescribeTagPattern())) {
Lazy<String> groupValue = Lazy.by(() -> describeTagPatternValues.get().get(groupName));
placeholderMap.put("describe.tag." + groupName, groupValue);
placeholderMap.put("describe.tag." + groupName + ".slug", Lazy.by(() -> slugify(groupValue.get())));
}
final Lazy<Matcher> descriptionTagVersionMatcher = Lazy.by(() -> matchVersion(descriptionTag.get()));
placeholderMap.put("describe.tag.version", Lazy.by(() -> requireNonNullElse(descriptionTagVersionMatcher.get().group("version"), "0.0.0")));
Note, that the describe.tag.version.slug placeholder still contains the text matched by the describe tag pattern.
Im am not sure how to fix this. Obviously, the easiest solution would be to change the example to use a different placeholder which does not collide with the describe.tag.version.* placeholders. However, I think a better solution would be to use the version matched by the describe tag pattern as the starting point for generating the describe.tag.version.* placeholders (I hope this makes sense).