https://github.com/oslomarketsolutions/pre-commit-maven-plugin
A Maven plugin for the pre-commit framework
https://github.com/oslomarketsolutions/pre-commit-maven-plugin
git git-hooks maven maven-plugin pre-commit
Last synced: 9 days ago
JSON representation
A Maven plugin for the pre-commit framework
- Host: GitHub
- URL: https://github.com/oslomarketsolutions/pre-commit-maven-plugin
- Owner: oslomarketsolutions
- License: apache-2.0
- Created: 2018-06-06T15:15:28.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-08-02T17:07:13.000Z (over 4 years ago)
- Last Synced: 2025-07-13T12:19:01.240Z (6 months ago)
- Topics: git, git-hooks, maven, maven-plugin, pre-commit
- Language: Java
- Homepage:
- Size: 77.1 KB
- Stars: 19
- Watchers: 3
- Forks: 7
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# pre-commit-maven-plugin
> A maven plugin for [the pre-commit framework][precommit]
[pre-commit][precommit] 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!
## Usage
First, follow the [setup instructions][setup] 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:
```xml
no.oms.maven
pre-commit-maven-plugin
LATEST_VERSION
false
v1.10.1
download-binary
generate-hooks
```
Remember to replace `LATEST_VERSION` with the version of the plugin you
would like to use, i.e. [the latest version][releases]. 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:
```xml
preCommit
prePush
commitMsg
```
### Options
> TODO
### 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 |
### Gitignore
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.
## FAQ
### 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/`.
## Developing
### Releasing new versions
Ensure you have access to [OSSRH][ossrh] and that your `~/.m2/settings.xml`
includes the following
```
ossrh
your_ossrh_username
your_ossrh_password
```
Run `mvn clean deploy -P release`
[precommit]: https://pre-commit.com
[setup]: https://pre-commit.com/#plugins
[releases]: https://github.com/oslomarketsolutions/pre-commit-maven-plugin/releases
[ossrh]: https://central.sonatype.org