Skip to content

Commit

Permalink
Add 'may-spotless-apply' profile (#611)
Browse files Browse the repository at this point in the history
I often find myself forgetting to apply spotless before committing.

On some repositories, I have set up a pre-commit git hook running `mvn
spotless:check`. However, this has to be set up on each repository that
has spotless check enabled, and disabled on those which don't.

I think this goes one step further, by defining a conventional maven
profile `may-spotless-apply` that will run `spotless:apply` *only* if
spotless is enabled for the given repository.

This allows any user to incorporate `-Pmay-spotless-apply` as part of
their usual build command (or defined in their maven settings active profiles section),
and have `spotless:apply` automatically called if the project has it enabled.
  • Loading branch information
Vlatombe authored Sep 24, 2024
1 parent 995e904 commit 61e475b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1014,5 +1014,28 @@
<yarn.lint.skip>true</yarn.lint.skip>
</properties>
</profile>
<profile>
<id>may-spotless-apply</id>
<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<executions>
<execution>
<id>spotless-apply</id>
<goals>
<goal>apply</goal>
</goals>
<phase>validate</phase>
<configuration>
<skip>${spotless.check.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit 61e475b

Please sign in to comment.