From 4e1ba6f729e865cbac34ab889744277ffb7affea Mon Sep 17 00:00:00 2001 From: "CORP\\mmrzik" Date: Tue, 28 Nov 2023 11:49:10 +0100 Subject: [PATCH] #13: implemented suggested improvements --- .../com/devonfw/tools/ide/common/SystemPath.java | 1 + .../devonfw/tools/ide/tool/ToolCommandlet.java | 3 ++- .../java/com/devonfw/tools/ide/tool/aws/Aws.java | 15 ++++++--------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cli/src/main/java/com/devonfw/tools/ide/common/SystemPath.java b/cli/src/main/java/com/devonfw/tools/ide/common/SystemPath.java index ac24d3a99..9219eea93 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/common/SystemPath.java +++ b/cli/src/main/java/com/devonfw/tools/ide/common/SystemPath.java @@ -166,6 +166,7 @@ public Path getPath(String tool) { */ public void setPath(String tool, Path path) { + this.paths.add(path); this.tool2pathMap.put(tool, path); } diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/ToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/ToolCommandlet.java index c0742e0a2..99dae1fa8 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/ToolCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/ToolCommandlet.java @@ -89,7 +89,7 @@ public void run() { * Ensures the tool is installed and then runs this tool with the given arguments. * * @param toolVersion the explicit version (pattern) to run. Typically {@code null} to ensure the configured version - * is installed and use that one. Otherwise the specified version will be installed in the software repository + * is installed and use that one. Otherwise, the specified version will be installed in the software repository * without touching and IDE installation and used to run. * @param args the commandline arguments to run the tool. */ @@ -276,6 +276,7 @@ protected void extract(Path file, Path targetDir) { } protected void moveAndProcessExtraction(Path from, Path to) { + this.context.getFileAccess().move(from, to); } diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/aws/Aws.java b/cli/src/main/java/com/devonfw/tools/ide/tool/aws/Aws.java index 525277606..0a6a9263c 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/aws/Aws.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/aws/Aws.java @@ -48,21 +48,19 @@ private void makeExecutable(Path file) { @Override protected void moveAndProcessExtraction(Path from, Path to) { - if (!this.context.getSystemInfo().isLinux()) { - this.context.getFileAccess().move(from, to); - } else { + if (this.context.getSystemInfo().isLinux()) { // make binary executable using java nio because unpacking didn't preserve the file permissions + // TODO this can be removed if issue #132 is fixed Path awsInDistPath = from.resolve("dist").resolve("aws"); Path awsCompleterInDistPath = from.resolve("dist").resolve("aws_completer"); - - // TODO this can be removed if issue #132 is fixed makeExecutable(awsInDistPath); makeExecutable(awsCompleterInDistPath); + // running the install-script that aws shipped ProcessContext pc = this.context.newProcess(); Path linuxInstallScript = from.resolve("install"); - pc.executable("bash"); - pc.addArgs(linuxInstallScript, "-i", from.toString(), "-b", from.toString()); + pc.executable(linuxInstallScript); + pc.addArgs("-i", from.toString(), "-b", from.toString()); pc.run(); // the install-script that aws ships creates symbolic links to binaries but using absolute paths @@ -74,9 +72,8 @@ protected void moveAndProcessExtraction(Path from, Path to) { } this.context.getFileAccess().delete(linuxInstallScript); this.context.getFileAccess().delete(from.resolve("dist")); - - this.context.getFileAccess().move(from, to); } + super.moveAndProcessExtraction(from, to); } @Override