Skip to content

videki/conventional-commits-for-java

 
 

Repository files navigation

Conventional Commits for Java

Build Test Codecov branch

Provides a Java implementation of Conventional Commits for projects built with Java 11+ using Git for version control.

Note: This is a fork of foo4u/conventional-commits-for-java.

Maven Plugin

This plugin works together with the Maven Release Plugin to create conventional commit compliant releases for your Maven projects.

Goals

validate

Checks whether the project has conventional commits compliant changes since the last release tag.

version

Calculates the release version for the maven release plugin based on the commit messages.

Usage

In your main pom.xml file add the plugin (for the latest version see the project tags or the Maven Central):

    <plugins>
        <plugin>
            <groupId>net.videki.semver</groupId>
            <artifactId>conventional-commits-maven-plugin</artifactId>
            <version>${version}</version>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
                <scmCommentPrefix>build(release): </scmCommentPrefix>
                <scmDevelopmentCommitComment>ci(release): open next snapshot version</scmDevelopmentCommitComment>
                <scmReleaseCommitComment>build(release): publish</scmReleaseCommitComment>
            </configuration>
        </plugin>
    </plugins>

In your CI code:

  • Execute only for master | main branch
  • skip builds for build(release) and ci(release) commits

GitHub workflow:

jobs:
  main:
    ...
    if: |
      "!contains(github.event.head_commit.message, 'build(release)')" &&
      "!contains(github.event.head_commit.message, 'ci(release)')"

Gitlab:

  only:
    variables:
      - '$CI_COMMIT_MESSAGE !~ /^(build|ci)\(release\):.+/'
      - '$CI_COMMIT_BRANCH =~ /^(master|main)/'

Release a Version

mvn conventional-commits:version release:prepare
mvn release:perform

Gradle Plugin

A [Gradle] plugin is planned for future release.

About

Conventional commits plugins for Java build systems. Maven only for now.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages

  • Java 99.8%
  • Groovy 0.2%