From 36c93694044c22ed8f005516f4cb6807db33fcec Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Fri, 23 Jan 2026 11:42:33 +0000 Subject: [PATCH] removal of old java desktop + workspace change in tauri (#5459) # Description of Changes --- ## 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. --- CLAUDE.md | 1 - .../configuration/InstallationPathConfig.java | 24 -------- app/core/build.gradle | 18 ------ .../software/SPDF/SPDFApplication.java | 30 ---------- .../resources/static/3rdPartyLicenses.json | 24 -------- docker/Dockerfile.unified | 1 - docker/Dockerfile.unified-lite | 1 - docker/backend/Dockerfile | 1 - docker/backend/Dockerfile.fat | 1 - docker/backend/Dockerfile.ultra-lite | 1 - docker/embedded/Dockerfile | 1 - docker/embedded/Dockerfile.fat | 1 - docker/embedded/Dockerfile.ultra-lite | 1 - frontend/src-tauri/src/commands/backend.rs | 58 ++++++++++++++++++- scripts/build-tauri-jlink.bat | 3 +- scripts/build-tauri-jlink.sh | 2 - 16 files changed, 56 insertions(+), 112 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index cb3d9048f..2c4cfa537 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -199,7 +199,6 @@ return useToolOperation({ - **Java Version**: Minimum JDK 17, supports and recommends JDK 21 - **Lombok**: Used extensively - ensure IDE plugin is installed -- **Desktop Mode**: Set `STIRLING_PDF_DESKTOP_UI=true` for desktop application mode - **File Persistence**: - **Backend**: Designed to be stateless - files are processed in memory/temp locations only - **Frontend**: Uses IndexedDB for client-side file storage and caching (with thumbnails) diff --git a/app/common/src/main/java/stirling/software/common/configuration/InstallationPathConfig.java b/app/common/src/main/java/stirling/software/common/configuration/InstallationPathConfig.java index cc5401f86..8050a1659 100644 --- a/app/common/src/main/java/stirling/software/common/configuration/InstallationPathConfig.java +++ b/app/common/src/main/java/stirling/software/common/configuration/InstallationPathConfig.java @@ -1,8 +1,6 @@ package stirling.software.common.configuration; import java.io.File; -import java.nio.file.Paths; -import java.util.Locale; import lombok.extern.slf4j.Slf4j; @@ -61,28 +59,6 @@ public class InstallationPathConfig { } private static String initializeBasePath() { - if (Boolean.parseBoolean(System.getProperty("STIRLING_PDF_DESKTOP_UI", "false"))) { - String os = System.getProperty("os.name").toLowerCase(Locale.ROOT); - if (os.contains("win")) { - return Paths.get( - System.getenv("APPDATA"), // parent path - "Stirling-PDF") - + File.separator; - } else if (os.contains("mac")) { - return Paths.get( - System.getProperty("user.home"), - "Library", - "Application Support", - "Stirling-PDF") - + File.separator; - } else { - return Paths.get( - System.getProperty("user.home"), // parent path - ".config", - "Stirling-PDF") - + File.separator; - } - } return "." + File.separator; } diff --git a/app/core/build.gradle b/app/core/build.gradle index 6f6f0987d..c30921503 100644 --- a/app/core/build.gradle +++ b/app/core/build.gradle @@ -38,13 +38,6 @@ spotless { } dependencies { - if (System.getenv('STIRLING_PDF_DESKTOP_UI') != 'false' - || (project.hasProperty('STIRLING_PDF_DESKTOP_UI') - && project.getProperty('STIRLING_PDF_DESKTOP_UI') != 'false')) { - implementation 'org.openjfx:javafx-controls:21' - implementation 'org.openjfx:javafx-swing:21' - } - if (System.getenv('DISABLE_ADDITIONAL_FEATURES') != 'true' || (project.hasProperty('DISABLE_ADDITIONAL_FEATURES') && System.getProperty('DISABLE_ADDITIONAL_FEATURES') != 'true')) { @@ -115,19 +108,8 @@ sourceSets { resources { srcDirs += ['../configs'] } - java { - if (System.getenv('STIRLING_PDF_DESKTOP_UI') == 'false') { - exclude 'stirling/software/SPDF/UI/impl/**' - } - - } } test { - java { - if (System.getenv('STIRLING_PDF_DESKTOP_UI') == 'false') { - exclude 'stirling/software/SPDF/UI/impl/**' - } - } } } diff --git a/app/core/src/main/java/stirling/software/SPDF/SPDFApplication.java b/app/core/src/main/java/stirling/software/SPDF/SPDFApplication.java index e913aefaf..bce73b25c 100644 --- a/app/core/src/main/java/stirling/software/SPDF/SPDFApplication.java +++ b/app/core/src/main/java/stirling/software/SPDF/SPDFApplication.java @@ -20,7 +20,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; import io.github.pixee.security.SystemCommand; import jakarta.annotation.PostConstruct; -import jakarta.annotation.PreDestroy; import lombok.extern.slf4j.Slf4j; @@ -28,7 +27,6 @@ import stirling.software.common.configuration.AppConfig; import stirling.software.common.configuration.ConfigInitializer; import stirling.software.common.configuration.InstallationPathConfig; import stirling.software.common.model.ApplicationProperties; -import stirling.software.common.util.UrlUtils; @Slf4j @EnableScheduling @@ -60,19 +58,6 @@ public class SPDFApplication { Properties props = new Properties(); - if (Boolean.parseBoolean(System.getProperty("STIRLING_PDF_DESKTOP_UI", "false"))) { - System.setProperty("java.awt.headless", "false"); - app.setHeadless(false); - props.put("java.awt.headless", "false"); - props.put("spring.main.web-application-type", "servlet"); - - int desiredPort = 8080; - String port = UrlUtils.findAvailablePort(desiredPort); - props.put("server.port", port); - System.setProperty("server.port", port); - log.info("Desktop UI mode: Using port {}", port); - } - app.setAdditionalProfiles(getActiveProfile(args)); ConfigInitializer initializer = new ConfigInitializer(); @@ -153,13 +138,6 @@ public class SPDFApplication { "Running in Tauri mode. Parent process PID: {}", parentPid != null ? parentPid : "not set"); } - // Desktop UI initialization removed - webBrowser dependency eliminated - // Keep backwards compatibility for STIRLING_PDF_DESKTOP_UI system property - if (Boolean.parseBoolean(System.getProperty("STIRLING_PDF_DESKTOP_UI", "false"))) { - log.info("Desktop UI mode enabled, but WebBrowser functionality has been removed"); - // webBrowser.initWebUI(url); // Removed - desktop UI eliminated - } - // Standard browser opening logic String browserOpenEnv = env.getProperty("BROWSER_OPEN"); boolean browserOpen = browserOpenEnv != null && "true".equalsIgnoreCase(browserOpenEnv); @@ -192,14 +170,6 @@ public class SPDFApplication { } } - @PreDestroy - public void cleanup() { - // webBrowser cleanup removed - desktop UI eliminated - // if (webBrowser != null) { - // webBrowser.cleanup(); - // } - } - @EventListener public void onWebServerInitialized(WebServerInitializedEvent event) { int actualPort = event.getWebServer().getPort(); diff --git a/app/core/src/main/resources/static/3rdPartyLicenses.json b/app/core/src/main/resources/static/3rdPartyLicenses.json index 71618c28c..d8289e0d9 100644 --- a/app/core/src/main/resources/static/3rdPartyLicenses.json +++ b/app/core/src/main/resources/static/3rdPartyLicenses.json @@ -1596,30 +1596,6 @@ "moduleLicense": "Mozilla Public License, Version 2.0", "moduleLicenseUrl": "http://www.mozilla.org/MPL/2.0/index.txt" }, - { - "moduleName": "org.openjfx:javafx-base", - "moduleVersion": "21", - "moduleLicense": "GPLv2+CE", - "moduleLicenseUrl": "https://openjdk.java.net/legal/gplv2+ce.html" - }, - { - "moduleName": "org.openjfx:javafx-controls", - "moduleVersion": "21", - "moduleLicense": "GPLv2+CE", - "moduleLicenseUrl": "https://openjdk.java.net/legal/gplv2+ce.html" - }, - { - "moduleName": "org.openjfx:javafx-graphics", - "moduleVersion": "21", - "moduleLicense": "GPLv2+CE", - "moduleLicenseUrl": "https://openjdk.java.net/legal/gplv2+ce.html" - }, - { - "moduleName": "org.openjfx:javafx-swing", - "moduleVersion": "21", - "moduleLicense": "GPLv2+CE", - "moduleLicenseUrl": "https://openjdk.java.net/legal/gplv2+ce.html" - }, { "moduleName": "org.opensaml:opensaml-core", "moduleVersion": "4.3.2", diff --git a/docker/Dockerfile.unified b/docker/Dockerfile.unified index 6d045b4f2..8807766e7 100644 --- a/docker/Dockerfile.unified +++ b/docker/Dockerfile.unified @@ -31,7 +31,6 @@ COPY . . # Build server-only JAR (no frontend, includes security features controlled by DOCKER_ENABLE_SECURITY at runtime) RUN DISABLE_ADDITIONAL_FEATURES=false \ - STIRLING_PDF_DESKTOP_UI=false \ ./gradlew clean build -x spotlessApply -x spotlessCheck -x test -x sonarqube # Stage 3: Final unified image diff --git a/docker/Dockerfile.unified-lite b/docker/Dockerfile.unified-lite index 264d03d67..fc0dc7114 100644 --- a/docker/Dockerfile.unified-lite +++ b/docker/Dockerfile.unified-lite @@ -30,7 +30,6 @@ WORKDIR /app COPY . . RUN DISABLE_ADDITIONAL_FEATURES=true \ - STIRLING_PDF_DESKTOP_UI=false \ ./gradlew clean build -x spotlessApply -x spotlessCheck -x test -x sonarqube # Stage 3: Final unified ultra-lite image diff --git a/docker/backend/Dockerfile b/docker/backend/Dockerfile index 8ebccfaf7..567fb873b 100644 --- a/docker/backend/Dockerfile +++ b/docker/backend/Dockerfile @@ -25,7 +25,6 @@ COPY . . # Build the application (server-only JAR - no UI, includes security features controlled at runtime) RUN DISABLE_ADDITIONAL_FEATURES=false \ - STIRLING_PDF_DESKTOP_UI=false \ ./gradlew clean build -x spotlessApply -x spotlessCheck -x test -x sonarqube # ======================================== diff --git a/docker/backend/Dockerfile.fat b/docker/backend/Dockerfile.fat index 8e31c27c0..a833efb26 100644 --- a/docker/backend/Dockerfile.fat +++ b/docker/backend/Dockerfile.fat @@ -25,7 +25,6 @@ COPY . . # Build the application (server-only JAR - no UI, includes security features controlled at runtime) RUN DISABLE_ADDITIONAL_FEATURES=false \ - STIRLING_PDF_DESKTOP_UI=false \ ./gradlew clean build -x spotlessApply -x spotlessCheck -x test -x sonarqube # ======================================== diff --git a/docker/backend/Dockerfile.ultra-lite b/docker/backend/Dockerfile.ultra-lite index bf1929234..7840df339 100644 --- a/docker/backend/Dockerfile.ultra-lite +++ b/docker/backend/Dockerfile.ultra-lite @@ -21,7 +21,6 @@ COPY . . # Build the application with DISABLE_ADDITIONAL_FEATURES=true RUN DISABLE_ADDITIONAL_FEATURES=true \ - STIRLING_PDF_DESKTOP_UI=false \ ./gradlew clean build -x spotlessApply -x spotlessCheck -x test -x sonarqube # ======================================== diff --git a/docker/embedded/Dockerfile b/docker/embedded/Dockerfile index cad7a6038..b1ab2bc1f 100644 --- a/docker/embedded/Dockerfile +++ b/docker/embedded/Dockerfile @@ -32,7 +32,6 @@ COPY . . # Build JAR with embedded frontend (includes security features controlled at runtime) RUN DISABLE_ADDITIONAL_FEATURES=false \ - STIRLING_PDF_DESKTOP_UI=false \ ./gradlew clean build -PbuildWithFrontend=true -x spotlessApply -x spotlessCheck -x test -x sonarqube # Stage 2: Runtime image based on Debian stable-slim diff --git a/docker/embedded/Dockerfile.fat b/docker/embedded/Dockerfile.fat index 047e256af..529a694e7 100644 --- a/docker/embedded/Dockerfile.fat +++ b/docker/embedded/Dockerfile.fat @@ -32,7 +32,6 @@ COPY . . # Build JAR with embedded frontend (includes security features controlled at runtime) RUN DISABLE_ADDITIONAL_FEATURES=false \ - STIRLING_PDF_DESKTOP_UI=false \ ./gradlew clean build -PbuildWithFrontend=true -x spotlessApply -x spotlessCheck -x test -x sonarqube # Stage 2: Runtime image based on Debian stable-slim diff --git a/docker/embedded/Dockerfile.ultra-lite b/docker/embedded/Dockerfile.ultra-lite index 96575a17e..145803d6b 100644 --- a/docker/embedded/Dockerfile.ultra-lite +++ b/docker/embedded/Dockerfile.ultra-lite @@ -32,7 +32,6 @@ COPY . . # Build ultra-lite JAR with embedded frontend (minimal features) RUN DISABLE_ADDITIONAL_FEATURES=true \ - STIRLING_PDF_DESKTOP_UI=false \ ./gradlew clean build -PbuildWithFrontend=true -x spotlessApply -x spotlessCheck -x test -x sonarqube # Stage 2: Runtime image diff --git a/frontend/src-tauri/src/commands/backend.rs b/frontend/src-tauri/src/commands/backend.rs index aed5f0b87..b79715a6b 100644 --- a/frontend/src-tauri/src/commands/backend.rs +++ b/frontend/src-tauri/src/commands/backend.rs @@ -1,7 +1,7 @@ use tauri_plugin_shell::ShellExt; use tauri::Manager; use std::sync::Mutex; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use crate::utils::add_log; use crate::state::connection_state::{AppConnectionState, ConnectionMode}; @@ -126,6 +126,45 @@ fn normalize_path(path: &PathBuf) -> PathBuf { } } +fn migrate_legacy_workspace(legacy_dir: &PathBuf, target_root: &PathBuf) -> std::io::Result<()> { + for entry in std::fs::read_dir(legacy_dir)? { + let entry = entry?; + let file_type = entry.file_type()?; + let src_path = entry.path(); + let dest_path = target_root.join(entry.file_name()); + + if file_type.is_dir() { + copy_dir_recursive(&src_path, &dest_path)?; + } else if file_type.is_file() { + if let Some(parent) = dest_path.parent() { + std::fs::create_dir_all(parent)?; + } + std::fs::copy(&src_path, &dest_path)?; + } + } + + Ok(()) +} + +fn copy_dir_recursive(src: &Path, dest: &Path) -> std::io::Result<()> { + std::fs::create_dir_all(dest)?; + + for entry in std::fs::read_dir(src)? { + let entry = entry?; + let file_type = entry.file_type()?; + let src_path = entry.path(); + let dest_path = dest.join(entry.file_name()); + + if file_type.is_dir() { + copy_dir_recursive(&src_path, &dest_path)?; + } else if file_type.is_file() { + std::fs::copy(&src_path, &dest_path)?; + } + } + + Ok(()) +} + // Create, configure and run the Java command to run Stirling-PDF JAR fn run_stirling_pdf_jar(app: &tauri::AppHandle, java_path: &PathBuf, jar_path: &PathBuf) -> Result<(), String> { // Get platform-specific application data directory for Tauri mode @@ -143,7 +182,8 @@ fn run_stirling_pdf_jar(app: &tauri::AppHandle, java_path: &PathBuf, jar_path: & // Create subdirectories for different purposes let config_dir = app_data_dir.join("configs"); let log_dir = app_data_dir.join("logs"); - let work_dir = app_data_dir.join("workspace"); + let work_dir = app_data_dir.clone(); + let legacy_work_dir = app_data_dir.join("workspace"); // Create all necessary directories std::fs::create_dir_all(&app_data_dir).ok(); @@ -151,6 +191,19 @@ fn run_stirling_pdf_jar(app: &tauri::AppHandle, java_path: &PathBuf, jar_path: & std::fs::create_dir_all(&work_dir).ok(); std::fs::create_dir_all(&config_dir).ok(); + // Migrate legacy workspace content into the app data root before launch. + if legacy_work_dir.exists() { + add_log(format!("📦 Migrating legacy workspace from {}", legacy_work_dir.display())); + if let Err(err) = migrate_legacy_workspace(&legacy_work_dir, &app_data_dir) { + add_log(format!("⚠️ Failed to migrate legacy workspace: {}", err)); + } else { + match std::fs::remove_dir_all(&legacy_work_dir) { + Ok(_) => add_log("✅ Removed legacy workspace directory after migration".to_string()), + Err(err) => add_log(format!("⚠️ Failed to remove legacy workspace: {}", err)), + } + } + } + add_log(format!("📁 App data directory: {}", app_data_dir.display())); add_log(format!("📁 Log directory: {}", log_dir.display())); add_log(format!("📁 Working directory: {}", work_dir.display())); @@ -162,7 +215,6 @@ fn run_stirling_pdf_jar(app: &tauri::AppHandle, java_path: &PathBuf, jar_path: & let java_options = vec![ "-Xmx2g", "-DBROWSER_OPEN=false", - "-DSTIRLING_PDF_DESKTOP_UI=false", "-DSTIRLING_PDF_TAURI_MODE=true", &log_path_option, "-Dlogging.file.name=stirling-pdf.log", diff --git a/scripts/build-tauri-jlink.bat b/scripts/build-tauri-jlink.bat index 16d143c10..b9e438715 100644 --- a/scripts/build-tauri-jlink.bat +++ b/scripts/build-tauri-jlink.bat @@ -96,7 +96,6 @@ echo REM Launch with bundled JRE >> "frontend\src-tauri\runtime\launch-stirling. 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" @@ -133,4 +132,4 @@ 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! \ No newline at end of file +echo ✅ The application will now run without requiring users to install Java! diff --git a/scripts/build-tauri-jlink.sh b/scripts/build-tauri-jlink.sh index ef39615d1..ec2b283af 100755 --- a/scripts/build-tauri-jlink.sh +++ b/scripts/build-tauri-jlink.sh @@ -159,7 +159,6 @@ fi "$JRE_DIR/bin/java" \ -Xmx2g \ -DBROWSER_OPEN=true \ - -DSTIRLING_PDF_DESKTOP_UI=false \ -jar "$STIRLING_JAR" \ "$@" EOF @@ -188,7 +187,6 @@ REM Launch with bundled JRE "%JRE_DIR%\bin\java.exe" ^ -Xmx2g ^ -DBROWSER_OPEN=true ^ - -DSTIRLING_PDF_DESKTOP_UI=false ^ -jar "%STIRLING_JAR%" ^ %* EOF