Skip to content

Commit

Permalink
Switch to spotless maven plugin with palantir formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
groldan committed Nov 29, 2024
1 parent 2e7016f commit 75f594e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 22 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ jobs:
java-version: '21'
cache: 'maven'

- name: Validate pom formatting
run: make lint-pom

- name: Validate source code formatting
run: |
make lint
run: make lint-java

- name: Test
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ docker-compose_datadir*
.env.yjp

hs_err_pid*.log

.spotless-index
22 changes: 18 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,26 @@ clean:
./mvnw clean

.PHONY: lint
lint:
./mvnw fmt:check sortpom:verify -Dsort.verifyFailOn=strict -Dsort.verifyFail=stop -ntp -T1C
lint: lint-pom lint-java

.PHONY: lint-pom
lint-pom:
./mvnw sortpom:verify -Dsort.verifyFailOn=strict -Dsort.verifyFail=stop -ntp -T1C

.PHONY: lint-java
lint-java:
./mvnw spotless:check -ntp -T1C

.PHONY: format
format:
./mvnw sortpom:sort fmt:format -ntp -T1C
format: format-pom format-java

.PHONY: format-pom
format-pom:
./mvnw sortpom:sort -ntp -T1C

.PHONY: format-java
format-java:
./mvnw spotless:apply -ntp -T1C

.PHONY: install
install:
Expand Down
41 changes: 25 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
</modules>
<properties>
<revision>1.9-SNAPSHOT</revision>
<fmt.action>format</fmt.action>
<fmt.skip>false</fmt.skip>
<spotless.action>apply</spotless.action>
<spotless.apply.skip>${fmt.skip}</spotless.apply.skip>
<pom.fmt.action>sort</pom.fmt.action>
<pom.fmt.skip>${fmt.skip}</pom.fmt.skip>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>
Expand Down Expand Up @@ -215,9 +218,9 @@
<pluginManagement>
<plugins>
<plugin>
<groupId>com.spotify.fmt</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>2.21.1</version>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.43.0</version>
</plugin>
<plugin>
<groupId>com.github.ekryd.sortpom</groupId>
Expand All @@ -242,37 +245,43 @@
<artifactId>sortpom-maven-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<keepBlankLines>true</keepBlankLines>
<spaceBeforeCloseEmptyElement>false</spaceBeforeCloseEmptyElement>
<createBackupFile>false</createBackupFile>
<lineSeparator>\n</lineSeparator>
<nrOfIndentSpace>2</nrOfIndentSpace>
<verifyFail>stop</verifyFail>
<verifyFailOn>strict</verifyFailOn>
<skip>${fmt.skip}</skip>
<skip>${pom.fmt.skip}</skip>
</configuration>
<executions>
<execution>
<id>sort</id>
<goals>
<goal>sort</goal>
<goal>${pom.fmt.action}</goal>
</goals>
<phase>validate</phase>
<phase>verify</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify.fmt</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<configuration>
<verbose>false</verbose>
<filesNamePattern>.*\.java</filesNamePattern>
<skip>${fmt.skip}</skip>
<style>aosp</style>
<java>
<palantirJavaFormat>
<version>2.50.0</version>
</palantirJavaFormat>
</java>
<upToDateChecking>
<enabled>true</enabled>
<indexFile>${project.basedir}/.spotless-index</indexFile>
</upToDateChecking>
</configuration>
<executions>
<execution>
<goals>
<goal>${fmt.action}</goal>
<goal>${spotless.action}</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
Expand Down

0 comments on commit 75f594e

Please sign in to comment.