
I’ve been using jgitver
for a long time. It has been embarrassing on multiple occasions because it’s unmaintained and hasn’t had a release in a very long time. I like to use the latest and greatest as part of my “N-0” lifestyle.
Today, I found my replacement.
Maven Git Versioning Extension
Here is the config I’m using.
<configuration xmlns="https://github.com/qoomon/maven-git-versioning-extension"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://github.com/qoomon/maven-git-versioning-extension https://qoomon.github.io/maven-git-versioning-extension/configuration-9.4.0.xsd">
<refs considerTagsOnBranches="true">
<ref type="tag">
<pattern><![CDATA[v(?<version>.*)]]></pattern>
<version>${ref.version}</version>
</ref>
<ref type="branch">
<pattern>(main|release.*)</pattern>
<version>${describe.tag.version.major}.${describe.tag.version.minor}.${describe.tag.version.patch.next}-SNAPSHOT</version>
</ref>
<ref type="branch">
<pattern><![CDATA[feature/(?<feature>.+)]]></pattern>
<version>${describe.tag.version}-${ref.feature}-SNAPSHOT</version>
</ref>
</refs>
<rev>
<version>${commit}</version>
</rev>
</configuration>
I use another Maven extension as well:
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>me.qoomon</groupId>
<artifactId>maven-git-versioning-extension</artifactId>
<version>9.8.1</version>
</extension>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.7.0</version>
</extension>
</extensions>
The
os-maven-plugin
gives me operating system and architecture info
That combination is a nice way to generate versions from tags that includes additional meta data.
[INFO] Successfully built image 'docker.io/dashaun/dev.dashaun.service.gateway:v0.0.24-aarch_64'
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.028 s
[INFO] Finished at: 2025-02-02T20:06:02-06:00
[INFO] ------------------------------------------------------------------------
Example output from ./mvnw spring-boot:build-image
Additionally, I like to use the Maven Wrapper and a [SDKman])(https://sdkman.io) .sdkmanrc
file in my repositories. I find that a good balanced developer experience with some declarative CICD.
I realize that I could replace the Maven Wrapper with another line in the .sdkmanrc file. I choose to leave it this way for two primary reasons.
- I generate most of my projects at start.spring.io which provides the Maven Wrapper for me.
- Because I’m using Maven Extensions, above, I need the .mvn directory anyway.
What other things do you like to see in your repositories?