From e5abc4823d40116dbb781ea0d860c0f30ce23aa1 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Mon, 4 Jul 2022 10:50:39 +0200 Subject: [PATCH] add detection for developement environment --- src/main/java/Bootstrapper.java | 8 +++++++- .../java/net/horizoncode/sysbackup/cli/CLIProcessor.java | 1 - .../java/net/horizoncode/sysbackup/tasks/TaskBuilder.java | 1 - 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/Bootstrapper.java b/src/main/java/Bootstrapper.java index 5c166a1..41ab6b2 100644 --- a/src/main/java/Bootstrapper.java +++ b/src/main/java/Bootstrapper.java @@ -7,12 +7,18 @@ public class Bootstrapper { public static void main(String[] args) throws URISyntaxException { + File jarFile = + new File(Bootstrapper.class.getProtectionDomain().getCodeSource().getLocation().toURI()); + File executionPath = new File( new File(Bootstrapper.class.getProtectionDomain().getCodeSource().getLocation().toURI()) .getParent()); + if (!jarFile.isFile()) System.out.println("Dev environment detected!"); + CLIProcessor cliProcessor = new CLIProcessor(); - cliProcessor.startCLI(args, executionPath); + cliProcessor.startCLI( + args, jarFile.isFile() ? executionPath : new File(System.getProperty("user.dir"))); } } diff --git a/src/main/java/net/horizoncode/sysbackup/cli/CLIProcessor.java b/src/main/java/net/horizoncode/sysbackup/cli/CLIProcessor.java index 4b9cef2..9053eee 100644 --- a/src/main/java/net/horizoncode/sysbackup/cli/CLIProcessor.java +++ b/src/main/java/net/horizoncode/sysbackup/cli/CLIProcessor.java @@ -90,7 +90,6 @@ public class CLIProcessor { return; } String fileName = args[1]; - System.out.println(executionPath.getAbsolutePath()); File tasksFolder = new File(executionPath, "tasks"); if (!tasksFolder.exists()) if (!tasksFolder.mkdir()) System.err.println("Failed to create tasks folder!"); diff --git a/src/main/java/net/horizoncode/sysbackup/tasks/TaskBuilder.java b/src/main/java/net/horizoncode/sysbackup/tasks/TaskBuilder.java index 0e4af32..f204c77 100644 --- a/src/main/java/net/horizoncode/sysbackup/tasks/TaskBuilder.java +++ b/src/main/java/net/horizoncode/sysbackup/tasks/TaskBuilder.java @@ -14,7 +14,6 @@ import java.text.SimpleDateFormat; import java.time.temporal.ChronoUnit; import java.util.Date; import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; import java.util.stream.IntStream; @Builder