Skip to content

Commit 7f5f443

Browse files
slachiewiczgnodet
andauthored
Add spotless plugin configuration (#169)
* Add spotless plugin configuration * Use two profiles for spotless --------- Co-authored-by: Guillaume Nodet <gnodet@gmail.com>
1 parent c69f81c commit 7f5f443

File tree

1 file changed

+91
-13
lines changed

1 file changed

+91
-13
lines changed

pom.xml

Lines changed: 91 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,11 @@ limitations under the License.
332332
<plexusDistMgmtSnapshotsUrl>https://oss.sonatype.org/content/repositories/plexus-snapshots</plexusDistMgmtSnapshotsUrl>
333333
<project.build.outputTimestamp>2023-05-06T22:13:46Z</project.build.outputTimestamp>
334334
<gpg.useagent>true</gpg.useagent>
335+
<spotless-maven-plugin.version>2.36.0</spotless-maven-plugin.version>
335336
<mavenPluginToolsVersion>3.9.0</mavenPluginToolsVersion>
336337
<mavenFluidoSkinVersion>1.11.2</mavenFluidoSkinVersion>
337338
<junit5Version>5.9.3</junit5Version>
339+
<spotless.action>check</spotless.action>
338340
</properties>
339341

340342
<dependencyManagement>
@@ -424,7 +426,8 @@ limitations under the License.
424426
<configuration>
425427
<quiet>true</quiet>
426428
<locale>en</locale>
427-
<notimestamp>true</notimestamp><!-- avoid noise for svn/gitpubsub -->
429+
<!-- avoid noise for svn/gitpubsub -->
430+
<notimestamp>true</notimestamp>
428431
</configuration>
429432
</plugin>
430433
<plugin>
@@ -550,6 +553,41 @@ limitations under the License.
550553
</execution>
551554
</executions>
552555
</plugin>
556+
<plugin>
557+
<groupId>com.diffplug.spotless</groupId>
558+
<artifactId>spotless-maven-plugin</artifactId>
559+
<version>${spotless-maven-plugin.version}</version>
560+
<configuration>
561+
<java>
562+
<!-- orders of used formatters are important -->
563+
<!-- eg. palantir override importOrder, so should be first -->
564+
<palantirJavaFormat />
565+
<removeUnusedImports />
566+
<importOrder>
567+
<order>javax,java,,\#</order>
568+
</importOrder>
569+
</java>
570+
<pom>
571+
<sortPom>
572+
<expandEmptyElements>false</expandEmptyElements>
573+
<!-- https://issues.apache.org/jira/browse/MRELEASE-1111 -->
574+
<spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
575+
</sortPom>
576+
</pom>
577+
<upToDateChecking>
578+
<enabled>true</enabled>
579+
</upToDateChecking>
580+
</configuration>
581+
<executions>
582+
<execution>
583+
<id>spotless-check</id>
584+
<goals>
585+
<goal>${spotless.action}</goal>
586+
</goals>
587+
<phase>process-sources</phase>
588+
</execution>
589+
</executions>
590+
</plugin>
553591
</plugins>
554592
</pluginManagement>
555593
<plugins>
@@ -641,18 +679,6 @@ limitations under the License.
641679
<groupId>org.apache.maven.plugins</groupId>
642680
<artifactId>maven-surefire-report-plugin</artifactId>
643681
</plugin>
644-
<plugin>
645-
<groupId>org.apache.maven.plugins</groupId>
646-
<artifactId>maven-checkstyle-plugin</artifactId>
647-
<reportSets>
648-
<reportSet>
649-
<id>default</id>
650-
<reports>
651-
<report>checkstyle</report>
652-
</reports>
653-
</reportSet>
654-
</reportSets>
655-
</plugin>
656682
<plugin>
657683
<groupId>org.apache.maven.plugins</groupId>
658684
<artifactId>maven-pmd-plugin</artifactId>
@@ -764,5 +790,57 @@ limitations under the License.
764790
</plugins>
765791
</build>
766792
</profile>
793+
794+
<profile>
795+
<id>java11+</id>
796+
<activation>
797+
<jdk>[11,)</jdk>
798+
</activation>
799+
800+
<properties>
801+
<maven.compiler.release>${javaVersion}</maven.compiler.release>
802+
<!-- configuration for checkstyle to use with spotless -->
803+
<checkstyle.spotless.config>config/maven_checks_nocodestyle.xml</checkstyle.spotless.config>
804+
</properties>
805+
806+
<build>
807+
<!--- newer versions of plugins requires JDK 11 -->
808+
<plugins>
809+
<plugin>
810+
<groupId>com.diffplug.spotless</groupId>
811+
<artifactId>spotless-maven-plugin</artifactId>
812+
</plugin>
813+
<plugin>
814+
<groupId>org.apache.maven.plugins</groupId>
815+
<artifactId>maven-checkstyle-plugin</artifactId>
816+
<configuration>
817+
<configLocation>${checkstyle.spotless.config}</configLocation>
818+
</configuration>
819+
</plugin>
820+
</plugins>
821+
</build>
822+
</profile>
823+
<profile>
824+
<id>format-check</id>
825+
<activation>
826+
<property>
827+
<name>!format</name>
828+
</property>
829+
</activation>
830+
<properties>
831+
<spotless.action>check</spotless.action>
832+
</properties>
833+
</profile>
834+
<profile>
835+
<id>format</id>
836+
<activation>
837+
<property>
838+
<name>format</name>
839+
</property>
840+
</activation>
841+
<properties>
842+
<spotless.action>apply</spotless.action>
843+
</properties>
844+
</profile>
767845
</profiles>
768846
</project>

0 commit comments

Comments
 (0)