Fork me on GitHub

How it works

During the Maven execution, right at the parse of the pom files, Paprika will get the current version number of each module, starting by looking for the last tag associated with the module. The format of the tags should be <artifactId>/<version>, the version part with a strict interpretation of the Semantic Versioning specification, so without any starting v. If since that last tag the file pom.xml or any file in the source directory have been modified (see Configuration observedPath), or if any dependency (including the parent hierarchy) have been modified or released, the module is considered modified. Some modification in pom.xml are tolerated: modifying <modules> or changing order in any list, like <properties> or <dependencies>, are ignored. To search the last tag or the last modification, Paprika will upstream the Git history, but only the first parent of each commit will be followed, as if we use --first-parent in git-log command. If the module is not modified since his last tag, the version number found in the tag is used. In case of modification, the minor version of the last tagged version is increased, the patch number is forced to 0 and the pre-release tags are SNAPSHOT and the name of the branch. The branch name is not added if the branch is white-listed (see Configuration nonQualifierBranches). If the branch name is added, any \/:'"<>|?* characters are replaced by a -. In case of detached HEAD, the branch name is guessed: Paprika will check if the HEAD commit id is equal to any Git reference starting by refs/heads/. If no references are found, Git references starting by refs/remotes/<repo>/ are also tested, where <repo> is the name of a remote repository. If still no references are found, the complete commit id of HEAD is used as the branch name.

Paprika can be bypassed by setting the system property paprika.skip with a value different of FALSE (case insensitive): launching Maven with maven clean -Dpaprika.skip or maven clean -Dpaprika.skip=true will disable all version replacement, leaving the modules versions to paprika. If the system property is not setted, Paprika will check also the environment variable PAPRIKA_SKIP.

The version placeholders paprika described in Installation are replaced in line during the parse of the pom.xml file. Some Maven properties are created by Paprika and can be used during the build, in other plugins configurations or in filtered resources. These properties are:

Note: the null commit id is 0000000000000000000000000000000000000000, which is 40 times ‘0’.

Note: A dirty module means that the module has some modifications in the working directory or in the index, and not yet committed.

Name Description
${paprika.tagCommit} Last commit id (SHA1) releasing the module. Set with the null commit id if the module has never been released.
${paprika.tagCommit.short} Shortened (9 characters) id of ${paprika.tagCommit}.
${paprika.refName} Name of the tag referencing the last released version. Set with HEAD if the module has never been released.
${paprika.baseVersion} Last released version. See Configuration initVersion for the default value.
${paprika.lastCommit} Last commit id (SHA1) modifying the module, or ${paprika.tagCommit} value if no modifications are found since that commit. Set with the null commit id if the module is dirty.
${paprika.lastCommit.short} Shortened (9 characters) id of ${paprika.lastCommit}.
${paprika.lastModification} Creation date of ${paprika.lastCommit}. Set with the date of the starting of mvn command if the module is dirty.
${paprika.snapshot} true if the module is dirty or has been modified since the last releasing tag, false otherwise (opposite of ${paprika.pristine}).
${paprika.pristine} true if the module has not been modified since the last releasing tag, false otherwise (opposite of ${paprika.snapshot}).
${paprika} Computed version of the module.
${paprika.analyzed} A list of all modules analyzed by Paprika.
${project.build.outputTimestamp} Copy of ${paprika.lastModification}. The value is defined only if no value are already set and if Configuration reproducible allowing it. See Maven reproducible builds for more informations.

Paprika inject also informations about every other modules which are included in the multi-module project. So, for each module <artifactId> (including the current module being build), the following properties are defined:

  • ${paprika.<artifactId>.lastCommit}
  • ${paprika.<artifactId>.lastCommit.short}
  • ${paprika.<artifactId>.lastModification}
  • ${paprika.<artifactId>.tagCommit}
  • ${paprika.<artifactId>.tagCommit.short}
  • ${paprika.<artifactId>.refName}
  • ${paprika.<artifactId>.baseVersion}
  • ${paprika.<artifactId>.snapshot}
  • ${paprika.<artifactId>.pristine}
  • ${paprika.<artifactId>}