Bind to maven phase is not working
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>
Any updates on this? I have exactly this problem. mvn spotless:check throws an error, however it doesn't in mvn verify with following config:
<executions>
<execution>
<id>spotless-check</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
Summary: Applying the spotless maven plugin to specific phases is not working.
It is working fine.
For example, having binded check to validate phase and apply to verify, running verify also applies spotless.
👀 What else is expected?
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 verifyexpected: the command should fail because spotless check failed actual: the command succeeds while writing files with spotless::apply
In maven's default lifecycle validate phase comes before verify, so with the configuration as in reproducer - :apply is applied first and only then :check is checking at the end.
And later phase includes all previous phases.
IMO - this deserves invalid label and to be closed as not planned.