From 75f594ec189952f4108968ec7e9a1882df14d998 Mon Sep 17 00:00:00 2001 From: Gabriel Roldan Date: Wed, 23 Oct 2024 11:59:42 -0300 Subject: [PATCH] Switch to spotless maven plugin with palantir formatting --- .github/workflows/pull-request.yaml | 6 +++-- .gitignore | 2 ++ Makefile | 22 +++++++++++++--- pom.xml | 41 ++++++++++++++++++----------- 4 files changed, 49 insertions(+), 22 deletions(-) diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 86b422239..da9b98e4d 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -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: | diff --git a/.gitignore b/.gitignore index 6305175bd..16027c07f 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,5 @@ docker-compose_datadir* .env.yjp hs_err_pid*.log + +.spotless-index diff --git a/Makefile b/Makefile index e507a40a3..1cc7e5b7e 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/pom.xml b/pom.xml index 1af25852a..962ed20fa 100644 --- a/pom.xml +++ b/pom.xml @@ -12,8 +12,11 @@ 1.9-SNAPSHOT - format false + apply + ${fmt.skip} + sort + ${fmt.skip} UTF-8 https://sonarcloud.io @@ -215,9 +218,9 @@ - com.spotify.fmt - fmt-maven-plugin - 2.21.1 + com.diffplug.spotless + spotless-maven-plugin + 2.43.0 com.github.ekryd.sortpom @@ -242,37 +245,43 @@ sortpom-maven-plugin UTF-8 + true + false false \n - 2 stop strict - ${fmt.skip} + ${pom.fmt.skip} - sort - sort + ${pom.fmt.action} - validate + verify - com.spotify.fmt - fmt-maven-plugin + com.diffplug.spotless + spotless-maven-plugin - false - .*\.java - ${fmt.skip} - + + + 2.50.0 + + + + true + ${project.basedir}/.spotless-index + - ${fmt.action} + ${spotless.action} + validate