From a08a98638bf484296111afa3a91a80c3dde706dc Mon Sep 17 00:00:00 2001 From: leonrohne27 Date: Thu, 21 Nov 2024 11:56:33 +0100 Subject: [PATCH] #739: undo changes, updated EnvironmentCommandlet undo changes of previous commit, except getMessageIdeHome()-method, as it is never used Changed isIdeHomeRequired() in EnvironmentCommandlet from true to false, as this was causing unwanted exceptions --- .../tools/ide/commandlet/EnvironmentCommandlet.java | 2 +- .../tools/ide/context/AbstractIdeContext.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandlet.java index 056a8deb5..a65c6cb6f 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandlet.java @@ -41,7 +41,7 @@ public String getName() { @Override public boolean isIdeHomeRequired() { - return true; + return false; } @Override diff --git a/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java b/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java index 64d5c2c84..f1f658754 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java +++ b/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java @@ -256,6 +256,11 @@ private String getMessageIdeHomeFound() { return "IDE environment variables have been set for " + this.ideHome + " in workspace " + this.workspaceName; } + private String getMessageIdeHomeNotFound() { + + return "You are not inside an IDE installation: " + this.cwd; + } + private static String getMessageIdeRootNotFound() { String root = System.getenv("IDE_ROOT"); if (root == null) { @@ -264,7 +269,7 @@ private static String getMessageIdeRootNotFound() { return "The environment variable IDE_ROOT is pointing to an invalid path " + root + ". Please reinstall IDEasy or manually repair IDE_ROOT variable."; } } - + /** * @return {@code true} if this is a test context for JUnits, {@code false} otherwise. */ @@ -278,6 +283,7 @@ protected SystemPath computeSystemPath() { return new SystemPath(this); } + private boolean isIdeHome(Path dir) { if (!Files.isDirectory(dir.resolve("workspaces"))) { @@ -803,7 +809,9 @@ private ValidationResult applyAndRun(CliArguments arguments, Commandlet cmd) { } if (result.isValid()) { debug("Running commandlet {}", cmd); - if (cmd.isIdeRootRequired() && (this.ideRoot == null)) { + if (cmd.isIdeHomeRequired() && (this.ideHome == null)) { + throw new CliException(getMessageIdeHomeNotFound(), ProcessResult.NO_IDE_HOME); + } else if (cmd.isIdeRootRequired() && (this.ideRoot == null)) { throw new CliException(getMessageIdeRootNotFound(), ProcessResult.NO_IDE_ROOT); } if (cmd.isProcessableOutput()) {