Skip to content

Cosium/git-code-format-maven-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Central Latest

Maven Git Code Format

A maven plugin that automatically deploys google-java-format code formatter as a pre-commit git hook.
On commit, the hook will automatically format staged java files.

Automatic code format activation

Add this to your maven project root pom.xml :

<build> <plugins> <plugin> <groupId>com.cosium.code</groupId> <artifactId>maven-git-code-format</artifactId> <version>${maven-git-code-format.version}</version> <executions> <execution> <goals> <goal>install-hooks</goal> </goals> </execution> </executions> </plugin> </plugins> </build>

Manual code formatting

mvn git-code-format:format-code -DglobPattern=**/*

Manual code format validation

mvn git-code-format:validate-code-format -DglobPattern=**/*

How the hook works

On the initialize maven phase, git-code-format:install-hooks installs a git pre-commit hook that looks like this :

#!/bin/bash /usr/share/apache-maven-3.5.0/bin/mvn git-code-format:on-pre-commit

On pre-commit git phase, the hook triggers the git-code-format:on-pre-commit which formats the code of the modified java files using google-java-format.

About

A maven plugin that automatically deploys code formatters as pre-commit git hook

Topics

Resources

License

Stars

Watchers

Forks

Contributors 14