Skip to content

Commit

Permalink
Add spotless plugin configuration (#169)
Browse files Browse the repository at this point in the history
* Add spotless plugin configuration
* Use two profiles for spotless
---------

Co-authored-by: Guillaume Nodet <gnodet@gmail.com>
  • Loading branch information
slachiewicz and gnodet committed May 16, 2023
1 parent c69f81c commit 7f5f443
Showing 1 changed file with 91 additions and 13 deletions.
104 changes: 91 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,11 @@ limitations under the License.
<plexusDistMgmtSnapshotsUrl>https://oss.sonatype.org/content/repositories/plexus-snapshots</plexusDistMgmtSnapshotsUrl>
<project.build.outputTimestamp>2023-05-06T22:13:46Z</project.build.outputTimestamp>
<gpg.useagent>true</gpg.useagent>
<spotless-maven-plugin.version>2.36.0</spotless-maven-plugin.version>
<mavenPluginToolsVersion>3.9.0</mavenPluginToolsVersion>
<mavenFluidoSkinVersion>1.11.2</mavenFluidoSkinVersion>
<junit5Version>5.9.3</junit5Version>
<spotless.action>check</spotless.action>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -424,7 +426,8 @@ limitations under the License.
<configuration>
<quiet>true</quiet>
<locale>en</locale>
<notimestamp>true</notimestamp><!-- avoid noise for svn/gitpubsub -->
<!-- avoid noise for svn/gitpubsub -->
<notimestamp>true</notimestamp>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -550,6 +553,41 @@ limitations under the License.
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless-maven-plugin.version}</version>
<configuration>
<java>
<!-- orders of used formatters are important -->
<!-- eg. palantir override importOrder, so should be first -->
<palantirJavaFormat />
<removeUnusedImports />
<importOrder>
<order>javax,java,,\#</order>
</importOrder>
</java>
<pom>
<sortPom>
<expandEmptyElements>false</expandEmptyElements>
<!-- https://issues.apache.org/jira/browse/MRELEASE-1111 -->
<spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
</sortPom>
</pom>
<upToDateChecking>
<enabled>true</enabled>
</upToDateChecking>
</configuration>
<executions>
<execution>
<id>spotless-check</id>
<goals>
<goal>${spotless.action}</goal>
</goals>
<phase>process-sources</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down Expand Up @@ -641,18 +679,6 @@ limitations under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<reportSets>
<reportSet>
<id>default</id>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
Expand Down Expand Up @@ -764,5 +790,57 @@ limitations under the License.
</plugins>
</build>
</profile>

<profile>
<id>java11+</id>
<activation>
<jdk>[11,)</jdk>
</activation>

<properties>
<maven.compiler.release>${javaVersion}</maven.compiler.release>
<!-- configuration for checkstyle to use with spotless -->
<checkstyle.spotless.config>config/maven_checks_nocodestyle.xml</checkstyle.spotless.config>
</properties>

<build>
<!--- newer versions of plugins requires JDK 11 -->
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>${checkstyle.spotless.config}</configLocation>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>format-check</id>
<activation>
<property>
<name>!format</name>
</property>
</activation>
<properties>
<spotless.action>check</spotless.action>
</properties>
</profile>
<profile>
<id>format</id>
<activation>
<property>
<name>format</name>
</property>
</activation>
<properties>
<spotless.action>apply</spotless.action>
</properties>
</profile>
</profiles>
</project>

0 comments on commit 7f5f443

Please sign in to comment.