<projectVersionPattern> An arbitrary regex to match project version, matching groups can be used as Format Placeholders (has to be a full match pattern)
<describeTagPattern> An arbitrary regex to match tag names for git describe command (has to be a full match pattern e.g. v(.+), default is .*
<updatePom> Enable(true)/disable(false) version and properties update in original pom file, default is false
ℹ….slug placeholders means all / characters will be replaced by -.
ℹ Final version will be slugified automatically, so no need to use ${….slug} placeholders in <version> format.
ℹ define placeholder default value (placeholder is not defined) like this ${name:-DEFAULT_VALUE}
e.g ${env.BUILD_NUMBER:-0} or ${env.BUILD_NUMBER:-local}
ℹ define placeholder overwrite value (placeholder is defined) like this ${name:+OVERWRITE_VALUE}
e.g ${dirty:-SNAPSHOT} resolves to -SNAPSHOT instead of -DIRTY
Placeholders
${env.VARIABLE} Value of environment variable VARIABLE
${property.name} Value of commandline property -Dname=value
${version}<version> set in pom.xml e.g. '1.2.3-SNAPSHOT'
${version.core} the core version component of ${version} e.g. '1.2.3'
${version.major} the major version component of ${version} e.g. '1'
${version.major.next} the ${version.major} increased by 1 e.g. '2'
${version.minor} the minor version component of ${version} e.g. '2'
${version.minor.next} the ${version.minor} increased by 1 e.g. '3'
${version.patch} the patch version component of ${version} e.g. '3'
${version.patch.next} the ${version.patch} increased by 1 e.g. '4'
${version.label} the version label of ${version} e.g. 'SNAPSHOT'
${version.label.prefixed} like ${version.label} with label separator e.g. '-SNAPSHOT'
Project Version Pattern Groups
Content of regex groups in <projectVersionPattern> can be addressed like this:
${dirty} If repository has untracked files or uncommitted changes this placeholder will resolve to -DIRTY, otherwise it will resolve to an empty string.
ℹ May lead to performance issue on very large projects (10,000+ files)
${dirty.snapshot} Like ${dirty}, but will resolve to -SNAPSHOT
${value} Original value of matching property (Only available within property format)
Parameters & Environment Variables
Disable Extension
Environment Variables
export VERSIONING_DISABLE=true
Command Line Parameters
mvn … -Dversioning.disable
Provide branch or tag name
Environment Variables
export VERSIONING_GIT_REF=$PROVIDED_REF e.g. refs/heads/main, refs/tags/v1.0.0 or refs/pull/1000/head
export VERSIONING_GIT_BRANCH=$PROVIDED_BRANCH_NAME e.g. main or refs/heads/main
export VERSIONING_GIT_TAG=$PROVIDED_TAG_NAME e.g. v1.0.0 or refs/tags/v1.0.0
git.worktree absolute path of git worktree directory
IDE Setup
IntelliJ - Multi Modules Projects
For a flawless experience you need to disable this extension during project import, otherwise you'll get errors for modules depending on another module.
To disable this extension during import add following Maven Importer VM options (Preferences > Build, Execution, Deployment > Build Tools > Maven > Importing > VM options for importer) -Dversioning.disable=true
Most CI/CD systems do checkouts in a detached HEAD state so no branch information is available, however they provide environment variables with this information.
You can provide those, by using Parameters & Environment Variables.
Native Support
GitHub Actions: if $GITHUB_ACTIONS == true, GITHUB_REF is considered
GitLab CI: if $GITLAB_CI == true, CI_COMMIT_BRANCH and CI_COMMIT_TAG are considered
Circle CI: if $CIRCLECI == true, CIRCLE_BRANCH and CIRCLE_TAG are considered
Jenkins: if JENKINS_HOME is set, BRANCH_NAME and TAG_NAME are considered
Manual Setup
Set following environment variables before running your mvn command
export VERSIONING_GIT_REF=$PROVIDED_REF;
$PROVIDED_REF value examples: refs/heads/main, refs/tags/v1.0.0 or refs/pull/1000/head
mvn verify
# Publishes this plugin to local Maven
mvn install
# Run integration tests after install, # integration tests will run with LATEST version of extension installed
mvn failsafe:integration-test
# Publishes this plugin to OSS Nexus.
GPG_TTY=$(tty) mvn clean deploy -P release -Dgpg.keyname=???
请发表评论