From 6cd64a22ba42f42d19e34c32f0dca0ce0ada9dba Mon Sep 17 00:00:00 2001 From: Ludy Date: Fri, 8 Aug 2025 11:36:30 +0200 Subject: [PATCH] build(local): simplify writeVersion task with WriteProperties plugin and enable build caching (#4139) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description of Changes - **What was changed**: - Replaced the custom `writeVersion` task in `build.gradle` with the built-in `WriteProperties` plugin configuration. - Updated `gradle.properties` to enable `org.gradle.caching` (uncommented) for local development. - **Why the change was made**: - To reduce boilerplate and leverage Gradle’s native property-writing capabilities for maintaining the version file. - To improve build performance by reusing outputs via the Gradle build cache. - **Scope**: - These updates only affect local development and do not change production or CI script --- ## 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. --- build.gradle | 27 +++++---------------------- gradle.properties | 3 ++- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/build.gradle b/build.gradle index 627d7b5c1..fd9abf7c8 100644 --- a/build.gradle +++ b/build.gradle @@ -65,28 +65,11 @@ allprojects { } } -tasks.register('writeVersion') { - def propsFile = file("$projectDir/app/common/src/main/resources/version.properties") - def propsDir = propsFile.parentFile - - doLast { - if (propsDir.exists()) { - if (propsFile.exists()) { - println "File exists: $propsFile" - } else { - println "$propsFile does not exist. Creating file." - propsFile.createNewFile() - } - } else { - println "Creating directory: $propsDir" - propsDir.mkdirs() - propsFile.createNewFile() - } - - def props = new Properties() - props.setProperty("version", version) - props.store(propsFile.newWriter(), null) - } +tasks.register('writeVersion', WriteProperties) { + outputFile = layout.projectDirectory.file('app/common/src/main/resources/version.properties') + println "Writing version.properties to ${outputFile.path}" + comment "${new Date()}" + property 'version', project.provider { project.version.toString() } } tasks.named('createExe') { diff --git a/gradle.properties b/gradle.properties index 9184cf5c6..8a390f592 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,7 @@ org.gradle.parallel=true # Enables build caching to reuse outputs from previous builds for faster execution -# org.gradle.caching=true +org.gradle.caching=true org.gradle.build-scan=true +# org.gradle.configuration-cache=true