Stirling-PDF/scripts/build-tauri-jlink.bat

134 lines
5.3 KiB
Batchfile
Raw Normal View History

@echo off
REM Build script for Tauri with JLink runtime bundling
REM This script creates a self-contained Java runtime for Stirling-PDF
echo 🔧 Building Stirling-PDF with JLink runtime for Tauri...
echo ▶ Checking Java environment...
java -version >nul 2>&1
if errorlevel 1 (
echo ❌ Java is not installed or not in PATH
exit /b 1
)
jlink --version >nul 2>&1
if errorlevel 1 (
echo ❌ jlink is not available. Please ensure you have a JDK ^(not just JRE^) installed.
exit /b 1
)
echo ✅ Java and jlink detected
echo ▶ Building Stirling-PDF JAR...
call gradlew.bat clean bootJar --no-daemon
if errorlevel 1 (
echo ❌ Failed to build Stirling-PDF JAR
exit /b 1
)
2025-07-02 11:01:13 +01:00
REM Find the built JAR(s)
2025-07-18 11:25:14 +01:00
echo ▶ Listing all built JAR files in app\core\build\libs:
V2 Tauri Build Actions (#3899) # Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## 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) ### 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: Connor Yoh <connor@stirlingpdf.com>
2025-07-22 17:30:58 +01:00
dir /b app\core\build\libs\stirling-pdf-*.jar
for %%f in (app\core\build\libs\stirling-pdf-*.jar) do set STIRLING_JAR=%%f
if not exist "%STIRLING_JAR%" (
echo ❌ No Stirling-PDF JAR found in build/libs/
exit /b 1
)
echo ✅ Built JAR: %STIRLING_JAR%
echo ▶ Creating Tauri directories...
if not exist "frontend\src-tauri\libs" mkdir "frontend\src-tauri\libs"
if not exist "frontend\src-tauri\runtime" mkdir "frontend\src-tauri\runtime"
echo ▶ Copying JAR to Tauri libs directory...
copy "%STIRLING_JAR%" "frontend\src-tauri\libs\"
echo ✅ JAR copied to frontend\src-tauri\libs\
2025-07-02 11:01:13 +01:00
REM Log out all JAR files now in the Tauri libs directory
echo ▶ Listing all JAR files in frontend\src-tauri\libs after copy:
V2 Tauri Build Actions (#3899) # Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## 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) ### 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: Connor Yoh <connor@stirlingpdf.com>
2025-07-22 17:30:58 +01:00
dir /b frontend\src-tauri\libs\stirling-pdf-*.jar
2025-07-02 11:01:13 +01:00
echo ▶ Creating custom JRE with jlink...
if exist "frontend\src-tauri\runtime\jre" rmdir /s /q "frontend\src-tauri\runtime\jre"
REM Use predefined module list for Windows (jdeps may not be available)
set MODULES=java.base,java.compiler,java.desktop,java.instrument,java.logging,java.management,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.security.jgss,java.security.sasl,java.sql,java.transaction.xa,java.xml,java.xml.crypto,jdk.crypto.ec,jdk.crypto.cryptoki,jdk.unsupported
echo ▶ Creating JLink runtime with modules: %MODULES%
jlink ^
--add-modules %MODULES% ^
--strip-debug ^
--compress=2 ^
--no-header-files ^
--no-man-pages ^
--output "frontend\src-tauri\runtime\jre"
if not exist "frontend\src-tauri\runtime\jre" (
echo ❌ Failed to create JLink runtime
exit /b 1
)
echo ✅ JLink runtime created at frontend\src-tauri\runtime\jre
echo ▶ Creating launcher scripts for testing...
REM Create Windows launcher script
echo @echo off > "frontend\src-tauri\runtime\launch-stirling.bat"
echo REM Launcher script for Stirling-PDF with bundled JRE >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo. >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo set SCRIPT_DIR=%%~dp0 >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo set JRE_DIR=%%SCRIPT_DIR%%jre >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo set LIBS_DIR=%%SCRIPT_DIR%%..\libs >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo. >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo REM Find the Stirling-PDF JAR >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo for %%%%f in ("%%LIBS_DIR%%\Stirling-PDF-*.jar") do set STIRLING_JAR=%%%%f >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo. >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo if not exist "%%STIRLING_JAR%%" ^( >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo echo ❌ Stirling-PDF JAR not found in %%LIBS_DIR%% >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo exit /b 1 >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo ^) >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo. >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo REM Launch with bundled JRE >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo "%%JRE_DIR%%\bin\java.exe" ^^ >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo -Xmx2g ^^ >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo -DBROWSER_OPEN=true ^^ >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo -DSTIRLING_PDF_DESKTOP_UI=false ^^ >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo -jar "%%STIRLING_JAR%%" ^^ >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo %%* >> "frontend\src-tauri\runtime\launch-stirling.bat"
echo ✅ Created launcher scripts for testing
echo ▶ Testing bundled JRE...
"frontend\src-tauri\runtime\jre\bin\java.exe" --version >nul 2>&1
if errorlevel 1 (
echo ❌ Bundled JRE test failed
exit /b 1
) else (
echo ✅ Bundled JRE works correctly
)
echo.
echo ✅ 🎉 JLink build setup completed successfully!
echo.
echo 📊 Summary:
echo • JAR: %STIRLING_JAR%
echo • Runtime: frontend\src-tauri\runtime\jre
echo • Modules: %MODULES%
echo.
echo 📋 Next steps:
echo 1. cd frontend
2025-07-04 18:16:19 +01:00
echo 2. npm run tauri-build
echo.
echo 💡 Testing:
echo • Test bundled runtime: frontend\src-tauri\runtime\launch-stirling.bat
echo • Tauri configuration already updated to include bundled JRE
echo.
echo 💡 Benefits:
echo • No external JRE dependency
echo • Smaller distribution size with custom runtime
echo • Better security with minimal required modules
echo • Consistent Java version across all deployments
echo.
echo ✅ The application will now run without requiring users to install Java!