Skip to content

This simple module demos how to use Conventional Commits, Git Hooks to enforce Conventional Commits and Semantic Versioning in a Java project built with Maven.

License

Notifications You must be signed in to change notification settings

dwmkerr/java-maven-standard-version-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Maven Standard Version Sample

This simple module demos how to use Conventional Commits, Git Hooks to enforce Conventional Commits and Semantic Versioning in a Java project built with Maven.

This is the companion project to the article Supercharge your Java Projects with Conventional Commits, Semantic Versioning and Semantic Releases.

Also, if you want to see what the code looks like after we've added the changelog etc, check the release branch.

Developer Guide

Make sure you have setup your local Git Hooks:

git config core.hooksPath .githooks

This will make sure your commit messages follow the Conventional Commits Specification.

Here's some handly commands:

Command Usage
./mvnw -B verify Run the tests.
./mvnw -B package Run the builds.

Semantic Versioning

This project uses standard-release to update the version in the pom.xml file from the changes in the history and to create the CHANGELOG.md file.

To setup semantic versioning and create the baseline changelog, run:

npx dwmkerr/standard-version --first-release --packageFiles pom.xml --bumpFiles pom.xml

Now any time you want to cut a new release, run:

npx dwmkerr/standard-version --packageFiles pom.xml --bumpFiles pom.xml

This will:

  • Update the CHANGELOG.md
  • Update the version number based on the commit history
  • Create a git tag with the new version number

Finally, just push the tag to trigger a deployment of the new version:

git push --follow-tags

Major Version Zero

As per the spec: https://semver.org/spec/v2.0.0.html#doesnt-this-discourage-rapid-development-and-fast-iteration please note that Major Version 0 (i.e. 0.x.y) is for about rapid development. Major changes do not increase the major version number - only the minor version number. This is in alignment with the semver spec, that reserves major version zero for rapid changes that are expected to break the API.

About

This simple module demos how to use Conventional Commits, Git Hooks to enforce Conventional Commits and Semantic Versioning in a Java project built with Maven.

Resources

License

Stars

Watchers

Forks

Packages

No packages published