title: How can I configure Gradle google-java-format plugin to run goJF in the build step?
body: <p>We wired <a href="https://github.com/sherter/google-java-format-gradle-plugin" rel="nofollow noreferrer">https://github.com/sherter/google-java-format-gradle-plugin</a> into our project per the readme.</p>
  
  <p>We also wired in a pre-commit hook to run the plugin before committing, which ensures that all of the code in a changelist is formatted before pushing it, which avoids errors in Jenkins when we run the <code>verGJF</code> task.</p>
  
  <p>But we have to keep remembering to run <code>goJF</code> locally before running <code>./gradlew build</code>, or the build fails with formatting errors.</p>
  
  <p>We worked around this by adding the <a href="https://plugins.jetbrains.com/plugin/8527-google-java-format" rel="nofollow noreferrer">https://plugins.jetbrains.com/plugin/8527-google-java-format</a> and <a href="https://plugins.jetbrains.com/plugin/7642-save-actions" rel="nofollow noreferrer">https://plugins.jetbrains.com/plugin/7642-save-actions</a> plugins for IntelliJ, enabling the google-java-format plugin, and configuring the save-actions plugin to format on save.</p>
  
  <p>But that's a lot of extra configuration a developer has to remember to go through, plus it means they can't format code the way they want while working on it, and only have it be reformatted at the point of build or commit.</p>
  
  <p>We'd prefer an all-Gradle solution, so that the <code>goJF</code> task is run before the <code>build</code> task (and before the <code>verGJF</code> task, which is already bound to the <code>build</code> task by the google-java-format Gradle plugin).</p>
  
  <p>We couldn't figure out how to do that. Does someone else know?</p>