Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#395 Uninstall graalvm successfully #397

Merged
merged 4 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import com.devonfw.tools.ide.property.ToolProperty;
import com.devonfw.tools.ide.tool.ToolCommandlet;

import java.nio.file.Files;
import java.nio.file.Path;

/**
* An internal {@link Commandlet} to uninstall a tool.
*/
Expand Down Expand Up @@ -39,22 +36,8 @@ public void run() {
for (int i = 0; i < this.tools.getValueCount(); i++) {
ToolCommandlet toolCommandlet = this.tools.getValue(i);

try {
String commandletName = toolCommandlet.getName();
Path softwarePath = context.getSoftwarePath().resolve(commandletName);
if (Files.exists(softwarePath)) {
try {
context.getFileAccess().delete(softwarePath);
this.context.success("Successfully uninstalled " + commandletName);
} catch (Exception e) {
this.context.error("Couldn't uninstall " + commandletName);
}
} else {
this.context.warning("An installed version of " + commandletName + " does not exist");
}
} catch (Exception e) {
this.context.error(e.getMessage());
}
toolCommandlet.uninstall();

}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package com.devonfw.tools.ide.tool;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.Set;

import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.io.FileAccess;
Expand All @@ -15,6 +9,12 @@
import com.devonfw.tools.ide.repo.ToolRepository;
import com.devonfw.tools.ide.version.VersionIdentifier;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.Set;

/**
* {@link ToolCommandlet} that is installed globally.
*/
Expand Down Expand Up @@ -143,4 +143,10 @@ protected boolean doInstall(boolean silent) {
postInstall();
return true;
}

@Override
public void uninstall() {
//TODO: handle "uninstall <globaltool>"
this.context.error("Couldn't uninstall " + this.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,27 @@ protected void postExtract(Path extractedDir) {

}

private ToolInstallation createToolInstallation(Path rootDir, VersionIdentifier resolvedVersion, Path toolVersionFile, boolean newInstallation) {
public void uninstall() {

try {
Path softwarePath = getToolPath();
if (Files.exists(softwarePath)) {
try {
context.getFileAccess().delete(softwarePath);
this.context.success("Successfully uninstalled " + this.tool);
} catch (Exception e) {
this.context.error("Couldn't uninstall " + this.tool);
}
} else {
this.context.warning("An installed version of " + this.tool + " does not exist");
}
} catch (Exception e) {
this.context.error(e.getMessage());
}
}

private ToolInstallation createToolInstallation(Path rootDir, VersionIdentifier resolvedVersion, Path toolVersionFile,
boolean newInstallation) {

Path linkDir = getMacOsHelper().findLinkDir(rootDir, this.tool);
Path binDir = linkDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ public String getInstalledEdition(Path toolPath) {

}

/**
* Uninstalls the {@link #getName() tool}.
*/
public abstract void uninstall();

/**
* List the available editions of this tool.
*/
Expand Down
Loading