Maven plugin should support skip
Many maven plug-ins support skipping the plug-in altogether when skip is set to true in the configuration. In a big tree of modules, that can be useful for supporting setting up reasonable defaults, and then opting out in modules where this is not necessary. So, e.g.:
<plugin> <groupId>com.diffplug.spotless</groupId> <artifactId>spotless-maven-plugin</artifactId> <configuration> <skip>true</skip> </configuration> </plugin>
Happy to merge a PR for this.
Unless I missed something, it seems to already be supported by the plugin as you can see in the source code.
Indeed with the next configuration:
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>apply</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
<configuration>
<skip>true</skip>
<java>
<googleJavaFormat />
</java>
</configuration>
</plugin>
If I launch my build, I can see in my console:
[INFO] --- spotless-maven-plugin:2.17.0:apply (default) @ java-ref-app-api ---
[INFO] Spotless apply skipped
[INFO]
You can also skip it using the properties spotless.apply.skip for the apply task and spotless.check.skip for the check task with a command of type mvn <phases> -Dspotless.apply.skip
Fixed by @tisonkun, available in plugin-maven 2.27.1.