Maven Plugin for project semantic versioning

maven release plugin
maven snapshot version format
maven-semantic-release
versions maven plugin jenkins
maven versions plugin
maven-dependency version
maven release plugin alternative
jenkins maven auto increment version

I'm looking for a maven plugin that will help me manage version names and codes of every build that is made on our CI environment. Something that will be able to attach a prefix to the main version code or even update it (not changing the pom.xml). For example:

project version: 2.0.1
git/svn revision: 2342334

jar output: name-2.0.1-2342334.jar
maven repo: ../path/to/local/maven/repo/<package path>/2.0.1-2342334/

The main requirements to this plugin are:

  • Must be in Maven Repository (which means that NO additional setting required to add this plugin in my pom.xml and run maven)
  • Must not edit the pom, each time it's applied
  • A configuration file, would be great, so I could manage the versioning process
  • Must be able to edit the output file metadata (so the version will be applied as if it was written in the pom.xml file in the first place)

So far I found only maven-buildmetadata-pluging but unfortunately it's not in Maven Repo, so I'm stuck. Any help would be great.

If you change the version of your artifact the pom has to reflect the change, cause otherwise it's not reproducible.

If you change something in your build process (like added versions, whatever) it has to be reflected in the pom file. Otherwise you can not reproduce the build process with the same result.

You have written not to change the pom file but maintaining a separate file. So the questions is: Why not using the pom file itself, cause it's intended exactly for that purpose.

Furthermore all informations which you mentioned by the maven-buildmetadata-plugin can be achived by using existing maven plugins (like build-helper-maven-plugin, buildnumber-maven-plugin).

The SCM information can be used by using the buildnumber-maven-plugin which provides information like SCM revision number (SVN or GIT hash).

An on the other hand if you don't like to change your pom file manually you can use either the versions-maven-plugin or the maven-release-plugin which automatically can change informations in your pom file and handle all these things automatically.

To maintain metadata in your producted artifacts you can configure all plugins (like ear, war, jar) etc. more or less like this where the buildNumber is comming from buildnumber-maven-plugin:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <version>${maven-jar-plugin.version}</version>
      <configuration>
        <archive>
          <addMavenDescriptor>true</addMavenDescriptor>
          <index>true</index>
          <manifest>
            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
          </manifest>
          <manifestEntries>
            <artifactId>${project.artifactId}</artifactId>
            <groupId>${project.groupId}</groupId>
            <version>${project.version}</version>
            <buildNumber>${buildNumber}</buildNumber>
          </manifestEntries>
        </archive>
      </configuration>
    </plugin>

And of course if you really like to use Maven you should have to use an repository manager as already mentioned like Artifactory or Nexus which make life easier.

sidohaakma/semver-maven-plugin, semver-maven-plugin. The semver-maven-plugin is used to determine the next version of a MAVEN project. Symantic versioning is used to specify the version  The gitflow-maven-plugin You may know the maven versions plugin, which easily allows for setting the versions inside your pom.xml files. However, this requires me to manually enter the new version.

Hosting your own maven repository is very easy, using either Nexus or Artifactory. You can also use the Artifactory cloud version (I'm not affiliated with them...) so it may solve your problem. BTW - a simple server with Apache does the trick as well, but with more work..,

Regarding the plugins: If you deploy snapshot applications then each gets its own version based on timestamp.

For releases another option is to run an svn info and put the result (or part of it) into the generated artifact. The information can then be accessed by the code.

Maven Plugin for project semantic versioning, If you change the version of your artifact the pom has to reflect the change, cause otherwise it's not reproducible. If you change something in  semver-maven-plugin. The semver-maven-plugin is used to determine the next version of a MAVEN project. Symantic versioning is used to specify the version symantics. Check: semver.org for more information. Usage. Include the following depedency in your pom.xml

I just would like to add (although the question is 5 years old and already has an accepted answer) that the Buildmetadata Maven Plugin was not available on the Maven Repo at first, but it is now (since late 2013). People who would like to give it a try find the artifact at the following locations :

  1. com.redhat.rcm.maven.plugin:buildmetadata-maven-plugin
  2. de.smartics.maven.plugin:buildmetadata-maven-plugin

Please note that the name has changed from maven-buildmetadata-plugin to buildmetadata-maven-plugin due to naming conventions.

I'm one of the "original" authors of this plugin at smartics. If you would like to use it, you probably would like to use the fork provided by Red Hat. To my knowledge the two versions do not differ very much and they have not been synced since there is just so much other stuff to do and the plugin seems to be feature stable. ;-)

The source code for both versions is also available on GitHub:

  1. release-engineering/buildmetadata-maven-plugin
  2. smartics/buildmetadata-maven-plugin

Enforcing Semantic Versioning, Introducing the Maven JAPICC Plugin. This plugin allows you to enforce semantic versioning rules on your java project. Prerequisites: Previous  If you are a Java developer and serious about semantic versioning, then checkout this open source semantic versioning checking tool. It is available on Maven Central and on GitHub, and it can check differences, validate version numbers, and suggest proper version numbers for your new jar release.

Maven – Maven CI Friendly Versions, Single Project Setup Based on the above pom you can build your project using​: mvn <artifactId>flatten-maven-plugin</artifactId>; <version>1.1.0</version>  maven-semantic-release is a plugin for semantic-release v15. This project will deploy a maven project to maven central instead of deploying a node.js project to npm. This tool is intended to be used on github projects that use a Travis-CI server.

Maven Release plugin – Update POM Versions, In some situations you may want an easy way to update the version numbers in each POM of a multi-module project. The update-versions goal  The plugin currently supports POM, SBT, and Build.scala. SemanticVersioning uses the values parsed from the build definition files in conjunction with the Jenkins build number to create a Semantic Versioning string. The string is stored in an build-environment variable (name is configurable).

Semantic versioning - Amit Desai, The maven dependency plugin has an analyze goal that identifies two types of dependency issues in a project: Dependencies that are  This is a Gradle settings-plugin that provides support for semantic versioning of builds. It is quite easy to use and extremely configurable. The plugin allows you to bump the major, minor, patch or pre-release version based on the latest version, which is identified from a git tag.

Comments
  • Thanks for your answer, but the problem is not in setting up Nexus or anything else for these purposes. The problem is that there can be more build environments for one project. For example the client can build the whole app on his side. But I don't have (and can't have) access to all douse build environments. That's way a global maven repo is required.
  • You should use custom properties to tag the different artifacts. For example with Artifactory, you can attach properties during Maven deploy.