spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Maven plugin should support skip

Open thegreystone opened this issue 6 years ago • 2 comments

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>

thegreystone avatar Nov 27 '19 18:11 thegreystone

Happy to merge a PR for this.

nedtwigg avatar Nov 27 '19 20:11 nedtwigg

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

essobedo avatar Oct 11 '21 08:10 essobedo

Fixed by @tisonkun, available in plugin-maven 2.27.1.

nedtwigg avatar Sep 28 '22 17:09 nedtwigg