Skip to content

Commit

Permalink
simplify life for using spotless, document property to de activate it
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Lamy <[email protected]>
  • Loading branch information
olamy committed Feb 14, 2024
1 parent ab10017 commit cad3667
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 34 deletions.
35 changes: 23 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,19 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<executions>
<execution>
<id>spotless-check</id>
<goals>
<goal>check</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
Expand Down Expand Up @@ -734,26 +747,24 @@
</build>

<profiles>
<profile>
<id>jdk8</id>
<activation>
<jdk>[1.8,]</jdk>
</activation>
<properties>
<!-- last version working with java 8 -->
<spotless-maven-plugin.version>2.30.0</spotless-maven-plugin.version>
</properties>
</profile>
<profile>
<id>java11+</id>
<activation>
<jdk>[11,)</jdk>
</activation>

<properties>
<maven.compiler.release>${mojo.java.target}</maven.compiler.release>
</properties>

<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<!-- only in parent, other projects must enable it by itself -->
<inherited>false</inherited>
</plugin>
</plugins>
</build>
</profile>

<profile>
Expand Down
24 changes: 2 additions & 22 deletions src/site/markdown/index.md.vm
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,15 @@ with options:
- other imports
- static import

In order to use `spotless` in your project, you should add to your pom.xml

Newer version of spotless requires JDK 11, so it must be add in profile unless your project requires 11 by default.
`spotless` will be activated in your project per default, if you don't want to use it

```xml
<properties>
<recommendedJavaBuildVersion>11</recommendedJavaBuildVersion>
<spotless.check.skip>true</spotless.check.skip>
</properties>

<profiles>
<profile>
<id>java11+</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
```

When `spotless` will be enabled, each build will be check according to correct code format.

To fix code, simply run:
```
mvn spotless:apply
Expand Down

0 comments on commit cad3667

Please sign in to comment.