diff --git a/.github/workflows/linter_formatter.yaml b/.github/workflows/linter_formatter.yaml index c53bb74..4b0fa29 100644 --- a/.github/workflows/linter_formatter.yaml +++ b/.github/workflows/linter_formatter.yaml @@ -27,12 +27,9 @@ jobs: run: npm init -y - name: Install deps run: | - npm install --save-dev \ - prettier@3.6.2 \ - prettier-plugin-java@2.7.7 \ - prettier-plugin-toml@2.0.6 + npm install --save-dev prettier@3.7.3 - name: Run Prettier - run: npx prettier --config .prettierrc.yaml --write . + run: npx prettier --config .prettierrc.yaml --ignore-path .prettierignore --write . - id: verify_format name: Verify no changes after formatting run: | diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..a9884ce --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +*.java +**/*.java diff --git a/.prettierrc.yaml b/.prettierrc.yaml index c500321..60eab52 100644 --- a/.prettierrc.yaml +++ b/.prettierrc.yaml @@ -1,8 +1,4 @@ --- -plugins: - - prettier-plugin-java - - prettier-plugin-toml - printWidth: 120 tabWidth: 2 useTabs: false @@ -16,11 +12,3 @@ objectWrap: collapse bracketSameLine: false arrowParens: always endOfLine: lf - -overrides: - - files: ["*.java"] - options: - tabWidth: 4 - - files: ["*.properties"] - options: - keySeparator: = diff --git a/build.gradle.kts b/build.gradle.kts index 351e81e..50b4d35 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,6 +4,7 @@ plugins { alias(libs.plugins.spring.boot) apply false alias(libs.plugins.spring.dependency.management) apply false alias(libs.plugins.graalvm.native) apply false + alias(libs.plugins.spotless) } group = "com.workastra" @@ -22,6 +23,7 @@ allprojects { subprojects { apply(plugin = "java") apply(plugin = "checkstyle") + apply(plugin = "com.diffplug.spotless") checkstyle { toolVersion = "12.1.2" @@ -33,4 +35,15 @@ subprojects { languageVersion.set(JavaLanguageVersion.of(25)) } } + + spotless { + java { + target("src/*/java/**/*.java") + + prettier(mapOf( + "prettier" to "3.7.3", + "prettier-plugin-java" to "2.7.7" + )).configFile(file("${rootDir}/java.prettierrc.yaml")) + } + } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b5f867c..0dd3f9a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,3 +8,4 @@ spring-boot-bom = { module = "org.springframework.boot:spring-boot-dependencies" spring-boot = { id = "org.springframework.boot", version.ref = "spring-boot" } spring-dependency-management = { id = "io.spring.dependency-management", version = "1.1.7" } graalvm-native = { id = "org.graalvm.buildtools.native", version = "0.11.3" } +spotless = { id = "com.diffplug.spotless", version = "8.1.0" } diff --git a/java.prettierrc.yaml b/java.prettierrc.yaml new file mode 100644 index 0000000..e3703f8 --- /dev/null +++ b/java.prettierrc.yaml @@ -0,0 +1,17 @@ +--- +plugins: + - prettier-plugin-java + +printWidth: 120 +tabWidth: 4 +useTabs: false +semi: true +singleQuote: false +quoteProps: as-needed +jsxSingleQuote: false +trailingComma: all +bracketSpacing: true +objectWrap: collapse +bracketSameLine: false +arrowParens: always +endOfLine: lf