title: How to format code according to google java format
body: <p><strong>Current state:</strong></p>
  
  <p>I have a project which is build with: Java 1.8.161, Maven 3.3.9, SpringBoot 2.0.1, tools: Jenkins and GitLab. I would like to use <a href="https://github.com/google/google-java-format" rel="noreferrer">google java format</a> as a standard for whole team.</p>
  
  <p><strong>My investigation / solution:</strong></p>
  
  <p>During the investigation I found <a href="https://github.com/coveo/fmt-maven-plugin" rel="noreferrer">solution</a>, which sounds really easy. Just update pom file with:</p>
  
  <pre><code>&lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;com.coveo&lt;/groupId&gt;
              &lt;artifactId&gt;fmt-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.5.0&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;format&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>And it works. If I run compile, package, verify, install or deploy Maven lifecycle the code is formatted.</p>
  
  <p><strong>Question:</strong></p>
  
  <p>How can I run this after i.e. each commit for all team members without any extra steps in their IDEA? Because right now, I need to run Maven before each commit. But during the run of an application it is not necessary, so the team can avoid it.. Which of course will lead to problems with history in git.</p>