I'm using maven spotless plugin to format java files, but it can't skip files. I used exclude and toggle off, neither works.
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.6.1</version>
<configuration>
<formats>
<format>
<!-- define the files to apply to -->
<includes>
<include>*.java</include>
</includes>
<excludes>
<exclude>api/**/RayCall.java</exclude>
<exclude>api/**/ActorCall.java</exclude>
<exclude>runtime/*/generated/**/*.*</exclude>
</excludes>
<!-- define the steps to apply to those files -->
<trimTrailingWhitespace/>
<endWithNewline/>
<indent>
<tabs>true</tabs>
<spacesPerTab>2</spacesPerTab>
</indent>
</format>
</formats>
<!-- define a language-specific format -->
<java>
<toggleOffOn>
<off>// Generated by `RayCallGenerator.java`. DO NOT EDIT.</off>
</toggleOffOn>
<googleJavaFormat>
<version>1.7</version>
<style>GOOGLE</style>
</googleJavaFormat>
</java>
</configuration>
</plugin>
According to
pom.xmlsnippet two different check was configured.In this section include / exclude pattern configured well and it works fine 2. Java format
In this case there are no include / exclude pattern configured so default will be used which is
Now it's easy to figure out Java formatter will analyze all java files. Fortunately
<java>formatter also supports<includes>and<excludes>so this will work: