A Maven plugin for the pre-commit framework
Branch: master
Clone or download
Latest commit 48bbae6 Dec 22, 2018



A maven plugin for the pre-commit framework

pre-commit is a framework for managing commit hooks in a Git repository. It makes working with commit hooks easier, but it has an issue. It requires that developers install a binary onto their system and manually installing the the hooks into their repo by running pre-commit install --install-hooks. We can do better than that!

When compiling a maven project, this plugin will install the git hooks automatically in the developer's Git project. One less thing to remember!


First, follow the setup instructions on pre-commit.com. A .pre-commit-config.yaml file in the root of the project is required for the plugin to work.

Add the following to your pom.xml under build plugins:

        <!-- The version of pre-commit you would like to use -->

Remember to replace LATEST_VERSION with the version of the plugin you would like to use, i.e. the latest version. This will register the plugin

Other hook types

If you're using other types of hooks than just precommit hooks, then you need to pass an argument specifying which hooks you would like the plugin to install. This is done by setting the hookTypes argument:




Skipping execution

If you need to skip parts of the plugin, you may do so using the following system properties:

Goal Property
download -Dskip.downloadprecommit
install -Dskip.installprecommit


After running the plugin, you will see a precommit_files directory in your project. This is where the plugin stores the pre-commit files so that they can be executed when generating the Git hooks.

You probably want to add this directory to your gitignore.


Hooks are outdated

If you use rev: master or something similar, you may encounter situations where pre-commit does not want to run the correct version of the hooks because it has cached an earlier version.

To fix this, try deleting the cache directory at ~/.cache/pre-commit/.


Releasing new versions

Ensure you have access to OSSRH and that your ~/.m2/settings.xml includes the following


Run mvn clean deploy -P release