Skip to content

About

A maven plugin that allows you to check (or determine) the next version of your module, based on the rules of Semantic Versioning.

Topics

Resources

Stars

37 stars

Watchers

0 watching

Forks

Repository files navigation

SemVer check

GitHub GitHub release (latest SemVer) GitHub Workflow Status

This maven plugin allows you to check (or determine) the next version of your module, based on the rules of Semantic Versioning.

Prerequisites

This plugin requires Maven 3.3.9 and Java 11 or higher to be able to run. Tested working on maven 4-RC4 and JDK 25.

Usage

There is an example project that has a minimum configuration but all options specified.

Add the following configuration to your pom.xml and set the VERSION_NUMBER to the latest version released.

<build>
    ...
    <plugins>
        ...
        <plugin>
            <artifactId>semver-check-maven-plugin</artifactId>
            <groupId>io.github.jagodevreede</groupId>
            <version>VERSION_NUMBER</version>
            <configuration>
                <haltOnFailure>true</haltOnFailure>
                <outputFileName>nextVersion.txt</outputFileName>
            </configuration>
            <executions>
                <execution>
                    <id>check</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        ...
    </plugins>
    ...
</build>

This plugin can be used with a multimodule project, an example project can be found here.

Configuration

The following configuration options are available:

Property name Default value Description
skip false If set to true then the build will skip the execution of this plugin
skipDependencyCheck false If set to true then the dependencies will not be compared to the previous version
haltOnFailure true If set to false then the build will not fail if the plugin encounter a problem, but only log a warning
ignoreSnapshots true If set to false then the plugin will also compare to SNAPSHOT versions if it can find any (in local repo's for example)
outputFileName nextVersion.txt The name of the file where the next version in plain text will be written to. This file is located in the target folder. If the property is left empty then no file will be created
writeFileOnNone true If set to false then the output file will not be written if the determined version upgrade type is none
overwriteOutputFile true If set to false then the output file will not be overwritten.
includePackages Only uses packages in the list and ignores any others, can be a comma separated list or a list of includePackage. Values are a regex pattern (See example project for example)
excludePackages Ignores packages can be a comma separated list or a list of excludePackage. Values are a regex pattern (See example project for example)
excludeFiles Ignores files in match the regex with given here. Can be a comma separated list or a list of excludeFile (See example project for example)
failOnIncorrectVersion false If set to true then if the semver mismatches the build will fail.
allowHigherVersions true Only has effect when failOnIncorrectVersion is set. If allowHigherVersions set to false it will also break if it detected a is lower then expected version.
annotationAddedStrategy MINOR Strategy to use when an annotation is added. Possible values: MAJOR, MINOR, PATCH, NONE
annotationRemovedStrategy MAJOR Strategy to use when an annotation is removed. Possible values: MAJOR, MINOR, PATCH, NONE.
multiModuleStrategy HIGHEST Strategy to use when a multi module project is detected. Possible values: HIGHEST, SEMVER
bomPath Location of a Bill of Materials file that holds dependency information about modules in this project, will be auto detected by default.
skipDeploy false If set to true and no version change is detected, skips both install and deploy for this module.

How is the semver type determined

Major

  • Changing the java version of the compiled classes to a higher version.
  • Removal of a public class, method, field or static variable.
  • Removal of a resource file
  • Removal of an annotation on a public API

Minor

  • Addition of a public class, method, annotation, field or static variable.
  • Removal of an annotation on a non public API

Patch

  • Any change that changes the byte code
  • Any change in a resource file (Note that files in META-INF/maven/ are ignored as they are generated by maven)
  • Any change in a dependency

Multi-Module Projects

This plugin supports multi-module Maven projects where each module declares its own independent version, rather than inheriting a version from a parent POM. Each module's JAR is compared against its own previously released version independently.

A typical multi-module setup uses a Bill-of-Materials (BOM) pattern:

my-monorepo/
├── pom.xml                           (aggregator, packaging=pom)
├── my-project-bom/                   (optional BOM, manages all versions)
│   └── pom.xml
├── my-project-core/                  (v1.5.0-SNAPSHOT)
│   └── pom.xml
├── my-project-api/                   (v3.2.1-SNAPSHOT)
│   └── pom.xml
├── my-project-service/               (v2.0.4-SNAPSHOT)
│   └── pom.xml
└── my-project-independent/           (v1.0.0-SNAPSHOT)
    └── pom.xml

Each module imports the BOM via <dependencyManagement> with <scope>import</scope>. The BOM lists all module versions in a single place, making version coordination across the project straightforward. The bomPath configuration property specifies the BOM location, or it is auto-detected by default.

The BOM module is optional. It is most useful when a repository contains different types of modules — for example, a stable API contract alongside implementation services that evolve independently. In this setup, the API module can remain at a stable version (e.g., 3.2.1) while internal services advance through their own version cycles, allowing consumers to rely on a consistent interface even as implementations change.

When a multi-module project is detected, the plugin uses multiModuleStrategy to determine how to handle version changes across modules. The default strategy, HIGHEST, bumps the version to match the highest change found across any module. HIGHEST is the strategy that a normal single version muiti-module project uses. Alternatives like SEMVER evaluate each module independently.

update-version does not lower an explicitly declared module version when the version computed from its last release is lower. This also applies to parent and BOM POMs and to references to reactor modules in dependency management. writeFileOnNone=false only controls output files from check; it does not change this version floor.

Known limitations

Java modules (JPMS) are not supported yet, tracked as issue #65

Getting involved

If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker, or better yet create a Pull Request

If you contribute to this project please follow the conventional commits specification for commit messages.

How to release

All automated with the github release action.

Prerequisites:

First set the correct version to be released:

mvn versions:set -DnewVersion=1.2.3

Tag this release with tag v1.2.3

Then stage the release:

mvn -Ppublication clean deploy -DaltDeploymentRepository=local::default::file://`pwd`/target/staging-deploy

The start the actual release:

mvn -Ppublication jreleaser:full-release Add dry drun if you first need to check what it will do: -Djreleaser.dry.run=true

Lastly set the next snapshot version:

mvn versions:set -DnewVersion=1.2.4-SNAPSHOT

Close the release in maven central at https://s01.oss.sonatype.org/#stagingRepositories


Open source licensing info

  1. LICENSE

About

A maven plugin that allows you to check (or determine) the next version of your module, based on the rules of Semantic Versioning.

Topics

Resources

Stars

37 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages