From 9e0f6dd2e138b475fc7689e9fdb754dea983e06b Mon Sep 17 00:00:00 2001 From: Ludy Date: Sun, 3 Aug 2025 00:14:03 +0200 Subject: [PATCH] style(spotless): centralize and expand formatting config in root build.gradle (#4098) # Description of Changes - Removed redundant `spotless` configurations from `app/common`, `app/core`, and `app/proprietary` modules. - Consolidated all formatting logic into the root `build.gradle` file. - Extended Spotless support to include: - YAML files (`*.yml`, `*.yaml`) - Gradle scripts (`*.gradle`, including nested `app/**/*.gradle`) - Updated `googleJavaFormatVersion` from `1.27.0` to `1.28.0`. This change improves maintainability by enforcing consistent formatting across all modules from a single location. Additionally, it ensures formatting is applied to Gradle and YAML files, which were previously unformatted. --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. --- app/common/build.gradle | 15 +++++++++++++-- app/core/build.gradle | 15 +++++++++++++-- app/proprietary/build.gradle | 17 ++++++++++++++--- build.gradle | 30 ++++++++++++------------------ 4 files changed, 52 insertions(+), 25 deletions(-) diff --git a/app/common/build.gradle b/app/common/build.gradle index 515a52a5c..7b210406e 100644 --- a/app/common/build.gradle +++ b/app/common/build.gradle @@ -4,8 +4,7 @@ bootRun { } spotless { java { - target sourceSets.main.allJava - target sourceSets.test.allJava + target 'src/**/java/**/*.java' googleJavaFormat(googleJavaFormatVersion).aosp().reorderImports(false) importOrder("java", "javax", "org", "com", "net", "io", "jakarta", "lombok", "me", "stirling") @@ -14,6 +13,18 @@ spotless { leadingTabsToSpaces() endWithNewline() } + yaml { + target '**/*.yml', '**/*.yaml' + trimTrailingWhitespace() + leadingTabsToSpaces() + endWithNewline() + } + format 'gradle', { + target '**/gradle/*.gradle', '**/*.gradle' + trimTrailingWhitespace() + leadingTabsToSpaces() + endWithNewline() + } } dependencies { api 'org.springframework.boot:spring-boot-starter-web' diff --git a/app/core/build.gradle b/app/core/build.gradle index 46aad111c..037a89497 100644 --- a/app/core/build.gradle +++ b/app/core/build.gradle @@ -14,8 +14,7 @@ configurations { spotless { java { - target sourceSets.main.allJava - target sourceSets.test.allJava + target 'src/**/java/**/*.java' googleJavaFormat(googleJavaFormatVersion).aosp().reorderImports(false) importOrder("java", "javax", "org", "com", "net", "io", "jakarta", "lombok", "me", "stirling") @@ -24,6 +23,18 @@ spotless { leadingTabsToSpaces() endWithNewline() } + yaml { + target '**/*.yml', '**/*.yaml' + trimTrailingWhitespace() + leadingTabsToSpaces() + endWithNewline() + } + format 'gradle', { + target '**/gradle/*.gradle', '**/*.gradle' + trimTrailingWhitespace() + leadingTabsToSpaces() + endWithNewline() + } } dependencies { diff --git a/app/proprietary/build.gradle b/app/proprietary/build.gradle index 467d8a138..80b61438a 100644 --- a/app/proprietary/build.gradle +++ b/app/proprietary/build.gradle @@ -5,9 +5,8 @@ bootRun { enabled = false } spotless { - java { - target sourceSets.main.allJava - target sourceSets.test.allJava + java { + target 'src/**/java/**/*.java' googleJavaFormat(googleJavaFormatVersion).aosp().reorderImports(false) importOrder("java", "javax", "org", "com", "net", "io", "jakarta", "lombok", "me", "stirling") @@ -16,6 +15,18 @@ spotless { leadingTabsToSpaces() endWithNewline() } + yaml { + target '**/*.yml', '**/*.yaml' + trimTrailingWhitespace() + leadingTabsToSpaces() + endWithNewline() + } + format 'gradle', { + target '**/gradle/*.gradle', '**/*.gradle' + trimTrailingWhitespace() + leadingTabsToSpaces() + endWithNewline() + } } dependencies { implementation project(':common') diff --git a/build.gradle b/build.gradle index ceb786ff0..554d92689 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ ext { springSecuritySamlVersion = "6.5.2" openSamlVersion = "4.3.2" commonmarkVersion = "0.25.0" - googleJavaFormatVersion = "1.27.0" + googleJavaFormatVersion = "1.28.0" tempJrePath = null } @@ -158,9 +158,9 @@ subprojects { useJUnitPlatform() } - tasks.named("processResources") { - dependsOn(rootProject.tasks.writeVersion) - } + tasks.named("processResources") { + dependsOn(rootProject.tasks.writeVersion) + } if (name == 'stirling-pdf') { apply plugin: 'org.springdoc.openapi-gradle-plugin' @@ -528,20 +528,14 @@ launch4j { } spotless { - java { - target sourceSets.main.allJava - target sourceSets.test.allJava - target project(':common').sourceSets.main.allJava - target project(':common').sourceSets.test.allJava - target project(':proprietary').sourceSets.main.allJava - target project(':proprietary').sourceSets.test.allJava - target project(':stirling-pdf').sourceSets.main.allJava - target project(':stirling-pdf').sourceSets.test.allJava - - googleJavaFormat(googleJavaFormatVersion).aosp().reorderImports(false) - - importOrder("java", "javax", "org", "com", "net", "io", "jakarta", "lombok", "me", "stirling") - toggleOffOn() + yaml { + target '*.yml', '*.yaml' + trimTrailingWhitespace() + leadingTabsToSpaces() + endWithNewline() + } + format 'gradle', { + target 'build.gradle', 'settings.gradle', 'gradle/*.gradle', 'gradle/**/*.gradle' trimTrailingWhitespace() leadingTabsToSpaces() endWithNewline()