diff --git a/build.gradle.kts b/build.gradle.kts index fb2277e7..db03baf8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,6 +5,7 @@ plugins { java application kotlin("jvm") version "1.9.22" + id("org.beryx.runtime") version "1.13.1" apply false } repositories { mavenCentral() @@ -17,10 +18,10 @@ subprojects { group = "com.lightcrafts" version = rootProject.file("lightcrafts/version.txt").readText().trim() application { + applicationName = "LightZone" applicationDefaultJvmArgs += listOf( "--add-exports=java.desktop/sun.awt.image=ALL-UNNAMED", "-Xmx512m", - "-Dlensfun.dir=./share/lensfun", ) } repositories { diff --git a/lightcrafts/src/main/java/com/lightcrafts/utils/Lensfun.java b/lightcrafts/src/main/java/com/lightcrafts/utils/Lensfun.java index 7b78a9f6..682ceb38 100644 --- a/lightcrafts/src/main/java/com/lightcrafts/utils/Lensfun.java +++ b/lightcrafts/src/main/java/com/lightcrafts/utils/Lensfun.java @@ -8,7 +8,6 @@ import lombok.RequiredArgsConstructor; import java.awt.*; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -34,12 +33,14 @@ public class Lensfun { private int _fullHeight; private static String pathName = ""; + static { if (!Platform.isLinux()) { - final String baseDirName = System.getProperty("lensfun.dir"); - try { - pathName = Files.find(Paths.get(baseDirName), 1, - (path, attr) -> attr.isDirectory() && path.getFileName().toString().startsWith("version_")) + final var appDir = Paths.get(System.getProperty("jpackage.app-path")).getParent(); + final var lensfunDir = appDir.resolve("app/share/lensfun"); + try (final var stream = Files.walk(lensfunDir, 1)) { + pathName = stream.filter(Files::isDirectory) + .filter(path -> path.getFileName().toString().startsWith("version_")) .findFirst() .orElse(Path.of("")) .toString(); diff --git a/lightcrafts/src/main/java/com/lightcrafts/utils/raw/DCRaw.java b/lightcrafts/src/main/java/com/lightcrafts/utils/raw/DCRaw.java index c521713e..1e36b2dc 100644 --- a/lightcrafts/src/main/java/com/lightcrafts/utils/raw/DCRaw.java +++ b/lightcrafts/src/main/java/com/lightcrafts/utils/raw/DCRaw.java @@ -24,6 +24,8 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.channels.FileChannel; +import java.nio.file.Path; +import java.nio.file.Paths; import java.time.Instant; import java.time.ZoneId; import java.time.LocalDateTime; @@ -171,13 +173,8 @@ private static String readln(InputStream s) { private static final String DCRAW_NAME = "dcraw_lz"; private static String DCRAW_PATH; static { - DCRAW_PATH = System.getProperty("java.library.path") + File.separatorChar + DCRAW_NAME; - if (! new File(DCRAW_PATH).canExecute()) { - String dir = System.getProperty("install4j.appDir"); - if (dir == null) - dir = "."; - DCRAW_PATH = dir + File.separatorChar + DCRAW_NAME; - } + final var appDir = Paths.get(System.getProperty("jpackage.app-path")).getParent(); + DCRAW_PATH = appDir.resolve("app").resolve(DCRAW_NAME).toString(); } private static String match(@NonNull String s, @NonNull String tag) { diff --git a/windows/build.gradle.kts b/windows/build.gradle.kts index f681a1e6..eb9d3bc4 100644 --- a/windows/build.gradle.kts +++ b/windows/build.gradle.kts @@ -1,6 +1,49 @@ +plugins { + id("org.beryx.runtime") +} dependencies { "implementation"(project(":lightcrafts")) } application { mainClass.set("com.lightcrafts.platform.windows.WindowsLauncher") } +tasks { + named("jpackage") { + doFirst { + copy { + from("products/") + include("share/**") + include("dcraw_lz*") + include("*.dll") + into("build/jpackage/LightZone/app") + } + } + } +} +runtime { + options.set(listOf("--strip-debug", "--compress", "2", "--no-header-files", "--no-man-pages")) + modules.set( + listOf( + "java.base", "java.desktop", "java.logging", "java.management", "java.prefs", "java.rmi", "jdk.management" + ) + ) + jpackage { + imageName = "LightZone" + installerName = "LightZone-Installer" + skipInstaller = false + installerOptions = + listOf( + "--win-dir-chooser", + "--win-menu-group", + "LightZone", + "--win-menu", + "--win-shortcut", + "--vendor", + "LightZone Project" + ) + imageOptions = listOf("--icon", "src/main/resources/icons/LightZone.ico") + } + launcher { + jvmArgs = listOf("--add-exports=java.desktop/sun.awt.image=ALL-UNNAMED") + } +} \ No newline at end of file