spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Bind to maven phase is not working

Open thahgr opened this issue 1 year ago • 0 comments

If you are submitting a bug, please include the following:

Summary: Applying the spotless maven plugin to specific phases is not working. For example, having binded check to validate phase and apply to verify, running verify also applies spotless. Plugin goals run correctly individually eg mvn spotless:check

public git repo with example: https://gitlab.com/thahgr/spotless-maven-phases-test

to reproduce

  • modify a file adding an incorrect identation (eg new line)
  • run mvn verify

expected: the command should fail because spotless check failed actual: the command succeeds while writing files with spotless::apply

versions: maven: 3.8.1 java: 17 spotless: 2.43.0 google-java-plugin: 1.22.0 os: Ubuntu 22.04.4 LTS

Spotless configuration

<configuration>
    <java>
        <importOrder/>
        <removeUnusedImports/>
        <googleJavaFormat>
            <version>${google.java.format.version}</version>
            <style>GOOGLE</style>
            <reflowLongStrings>true</reflowLongStrings>
        </googleJavaFormat>
    </java>
    <lineEndings>UNIX</lineEndings>
</configuration>
<executions>
    <execution>
        <id>spotless-check</id>
        <goals>
            <goal>check</goal>
        </goals>
        <phase>verify</phase>
    </execution>
    <execution>
        <id>spotless-apply</id>
        <goals>
            <goal>apply</goal>
        </goals>
        <phase>validate</phase>
    </execution>
</executions>

thahgr avatar May 14 '24 08:05 thahgr