From 1ded9abb46589808f2c1d1a568295d76f292b352 Mon Sep 17 00:00:00 2001 From: Ludy Date: Fri, 20 Feb 2026 12:12:27 +0100 Subject: [PATCH] build(tauri): enforce Java 17+ requirement in Windows jlink build script (#5684) # Description of Changes This pull request improves the `scripts/build-tauri-jlink.bat` build script by adding a check to ensure that Java 17 or higher is installed before proceeding. This helps prevent build errors due to incompatible Java versions. Build process enhancements: * Added logic to parse the installed Java version and verify that it is at least version 17; the script now exits with an error message if an older version is detected. * Updated status messages to clearly indicate the Java version being used and to provide feedback if requirements are not met. --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] 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) - [ ] I have performed a self-review of my own code - [ ] 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) ### Translations (if applicable) - [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### 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. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- scripts/build-tauri-jlink.bat | 43 ++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/scripts/build-tauri-jlink.bat b/scripts/build-tauri-jlink.bat index b9e438715..05d839016 100644 --- a/scripts/build-tauri-jlink.bat +++ b/scripts/build-tauri-jlink.bat @@ -17,7 +17,48 @@ if errorlevel 1 ( exit /b 1 ) -echo ✅ Java and jlink detected +echo ▶ Checking Java version... +set "JAVA_VERSION_STRING=" +for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do ( + set "JAVA_VERSION_STRING=%%g" +) +if not defined JAVA_VERSION_STRING ( + echo ❌ Unable to capture Java version string from "java -version" + exit /b 1 +) +set "JAVA_VERSION_STRING=%JAVA_VERSION_STRING:"=%" +set "JAVA_MAJOR_VERSION=" +set "JAVA_MINOR_VERSION=0" +set "JAVA_EFFECTIVE_MAJOR=" +for /f "tokens=1,2 delims=." %%a in ("%JAVA_VERSION_STRING%") do ( + set "JAVA_MAJOR_VERSION=%%a" + set "JAVA_MINOR_VERSION=%%b" + if "%%a"=="1" ( + set "JAVA_EFFECTIVE_MAJOR=%%b" + ) else ( + set "JAVA_EFFECTIVE_MAJOR=%%a" + ) +) +if not defined JAVA_MAJOR_VERSION ( + echo ❌ Unable to determine Java major version from "%JAVA_VERSION_STRING%" + exit /b 1 +) +if not defined JAVA_EFFECTIVE_MAJOR ( + echo ❌ Unable to determine an effective Java major version from "%JAVA_VERSION_STRING%" + exit /b 1 +) +for /f "tokens=1 delims=.-" %%c in ("%JAVA_EFFECTIVE_MAJOR%") do set "JAVA_EFFECTIVE_MAJOR=%%c" +set /a "JAVA_EFFECTIVE_MAJOR_NUM=%JAVA_EFFECTIVE_MAJOR%" >nul 2>&1 +if errorlevel 1 ( + echo ❌ Java major version "%JAVA_EFFECTIVE_MAJOR%" could not be parsed as an integer. Detected string: "%JAVA_VERSION_STRING%" + exit /b 1 +) +set "JAVA_EFFECTIVE_MAJOR=%JAVA_EFFECTIVE_MAJOR_NUM%" +if %JAVA_EFFECTIVE_MAJOR% LSS 17 ( + echo ❌ Java 17 or higher is required. Found Java %JAVA_EFFECTIVE_MAJOR% + exit /b 1 +) +echo ✅ Java %JAVA_EFFECTIVE_MAJOR% and jlink detected echo ▶ Building Stirling-PDF JAR...