Skip to content

Instantly share code, notes, and snippets.

@jmbataller
Created September 12, 2019 14:10
Show Gist options
  • Save jmbataller/56717ecaacb09108c2c60d0f25e10f33 to your computer and use it in GitHub Desktop.
Save jmbataller/56717ecaacb09108c2c60d0f25e10f33 to your computer and use it in GitHub Desktop.
Checkstyle
Checkstyle rules (xml files):
https://github.com/checkstyle/checkstyle/tree/master/src/main/resources
Google Java style guide:
https://checkstyle.sourceforge.io/styleguides/google-java-style-20180523/javaguide.html
Maven plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<!--
This declaration merges with the one in the parent, rather
than overriding it, so we need to disable the "validate" phase
execution that the parent declares and declare our own
during "test-compile".
One reason for this is that avro codegen runs during compile,
and while it's not strictly a precondition, it's
confusing to address style violations while the IDE is telling you
that some generated class doesn't exist. Test-compile is the first phase
that's guaranteed to run after compile and before any unit or integration
tests.
Also, we want to disable the parent's configuration because it declares stuff
we don't care about, like suppressions. (Honestly, it shouldn't)
-->
<execution>
<id>validate</id>
<phase>none</phase>
<configuration>
<skip>true</skip>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<configuration>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
<includeResources>false</includeResources>
<includeTestResources>false</includeTestResources>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<excludes>io/confluent/examples/streams/avro/**</excludes>
<configLocation>checkstyle.xml</configLocation>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment