Skip to content

Commit 5cf051a

Browse files
areinickehohwille
andauthored
#1880: Allow reset of installed plugins when launching IDE in force mode (#1891)
Co-authored-by: Jörg Hohwiller <hohwille@users.noreply.github.com>
1 parent b77c017 commit 5cf051a

5 files changed

Lines changed: 43 additions & 10 deletions

File tree

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Release with new features and bugfixes:
2222
* https://github.com/devonfw/IDEasy/issues/1853[#1853]: Add ARM releases for VSCode on Mac
2323
* https://github.com/devonfw/IDEasy/issues/797[#797]: Use system unzip on macOS to preserve symlinks in ZIP extraction
2424
* https://github.com/devonfw/IDEasy/issues/1723[#1723]: Add commandlet for GitHub Copilot CLI
25+
* https://github.com/devonfw/IDEasy/issues/1880[#1880]: Reinstall all plugins for IDE in force mode
2526
* https://github.com/devonfw/IDEasy/issues/861[#861]: Fix install of pgadmin throws IllegalStateException when the install wizard starts
2627
* https://github.com/devonfw/IDEasy/issues/1844[#1844]: VSCode plugin installation progress freezing
2728
* https://github.com/devonfw/IDEasy/issues/1456[#1456]: Uninstall via Windows settings not working

cli/src/main/java/com/devonfw/tools/ide/tool/plugin/PluginBasedCommandlet.java

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.devonfw.tools.ide.io.FileAccess;
1616
import com.devonfw.tools.ide.process.ProcessContext;
1717
import com.devonfw.tools.ide.process.ProcessErrorHandling;
18+
import com.devonfw.tools.ide.property.FlagProperty;
1819
import com.devonfw.tools.ide.step.Step;
1920
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
2021
import com.devonfw.tools.ide.tool.ToolInstallRequest;
@@ -29,6 +30,9 @@ public abstract class PluginBasedCommandlet extends LocalToolCommandlet {
2930

3031
private ToolPlugins plugins;
3132

33+
/** {@link FlagProperty} to force the reset and reinstallation of plugins as configured in the project settings. */
34+
public FlagProperty forcePluginReinstall;
35+
3236
/**
3337
* The constructor.
3438
*
@@ -41,6 +45,12 @@ public PluginBasedCommandlet(IdeContext context, String tool, Set<Tag> tags) {
4145
super(context, tool, tags);
4246
}
4347

48+
@Override
49+
protected void initProperties() {
50+
this.forcePluginReinstall = add(new FlagProperty("--force-plugin-reinstall"));
51+
super.initProperties();
52+
}
53+
4454
/**
4555
* @return the {@link ToolPlugins} of this {@link PluginBasedCommandlet}.
4656
*/
@@ -108,19 +118,30 @@ protected void postInstall(ToolInstallRequest request) {
108118

109119
super.postInstall(request);
110120
Path pluginsInstallationPath = getPluginsInstallationPath();
121+
122+
if (!request.isAlreadyInstalled() || this.forcePluginReinstall.isTrue()) {
123+
LOG.info("Resetting all installed plugins...");
124+
deleteAllPlugins(pluginsInstallationPath);
125+
}
126+
this.context.getFileAccess().mkdirs(pluginsInstallationPath);
127+
installPlugins(request.getProcessContext());
128+
}
129+
130+
/**
131+
* Deletes all installed plugins for this {@link IdeToolCommandlet} by deleting the plugins installation folder and all plugin marker files.
132+
* @param pluginsInstallationPath the {@link Path} to the plugins installation folder.
133+
*/
134+
private void deleteAllPlugins(Path pluginsInstallationPath) {
135+
111136
FileAccess fileAccess = this.context.getFileAccess();
112-
if (!request.isAlreadyInstalled()) {
113-
fileAccess.delete(pluginsInstallationPath);
114-
List<Path> markerFiles = fileAccess.listChildren(this.context.getIdeHome().resolve(IdeContext.FOLDER_DOT_IDE), Files::isRegularFile);
115-
for (Path path : markerFiles) {
116-
if (path.getFileName().toString().startsWith("plugin." + getName())) {
117-
LOG.debug("Plugin marker file {} got deleted.", path);
118-
fileAccess.delete(path);
119-
}
137+
fileAccess.delete(pluginsInstallationPath);
138+
List<Path> markerFiles = fileAccess.listChildren(this.context.getIdeHome().resolve(IdeContext.FOLDER_DOT_IDE), Files::isRegularFile);
139+
for (Path path : markerFiles) {
140+
if (path.getFileName().toString().startsWith("plugin." + getName())) {
141+
fileAccess.delete(path);
142+
LOG.debug("Plugin marker file {} got deleted.", path);
120143
}
121144
}
122-
fileAccess.mkdirs(pluginsInstallationPath);
123-
installPlugins(request.getProcessContext());
124145
}
125146

126147
private void installPlugins(ProcessContext pc) {

cli/src/main/resources/nls/Help.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ opt.--batch=enable batch mode (non-interactive).
156156
opt.--code=clone given code repository containing a settings folder into workspaces so that settings can be committed alongside code changes.
157157
opt.--debug=enable debug logging.
158158
opt.--force=enable force mode.
159+
opt.--force-plugin-reinstall=resets installed plugins to the project configuration
159160
opt.--force-plugins=force plugin (re)installation.
160161
opt.--force-pull=force pull of settings even for code repository.
161162
opt.--force-repositories=force setup of repositories to even clone inactive and pull existing ones.

cli/src/main/resources/nls/Help_de.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ opt.--batch=Aktiviert den Batch-Modus (nicht-interaktive Stapelverarbeitung).
156156
opt.--code=Git-Repository sowohl als Code- als auch als Settings-Repository verwenden.
157157
opt.--debug=Aktiviert Debug-Ausgaben (Fehleranalyse).
158158
opt.--force=Aktiviert den Force-Modus (Erzwingen).
159+
opt.--force-plugin-reinstall=Setzt installierte Plugins zurück auf die Projektkonfiguration.
159160
opt.--force-plugins=Erzwingt die (Re)Installation von Plugins.
160161
opt.--force-pull=Erzwingt einen Pull der settings auch im Fall eines Code-Repositories.
161162
opt.--force-repositories=Erzwingt das Setup von Repositories um auch Inaktive zu clonen oder Existierende zu pullen.

documentation/plugin.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ For `VisualStudio Code`, this is the extension ID you can directly get from the
3131
|`active`|`true`|(optional) `true` to tell IDEasy that this plugin shall be installed automatically for everybody in your team. Default is `false`. If not auto-installed, it can still be installed via `ide install-plugin «ide» «plugin»`.
3232
|`tags`|e.g. `java,spring,ai`|(optional) Tags to classify the plugin. Will be used by the GUI of IDEasy for selection by tag.
3333
|===
34+
35+
36+
== Resetting installed plugins
37+
38+
When first installing an IDE using `ide install «ide»`, IDEasy will automatically install all plugins that are configured in the project settings.
39+
This configuration is intended to serve as a baseline for the entire team.
40+
However, after the initial setup, you can freely change the plugin configuration for your IDE as you see fit.
41+
42+
To revert to the initial plugin configuration, you can run `ide «ide» --force-plugin-reinstall`, which will uninstall all currently installed plugins and reinstall them as configured in the project settings.

0 commit comments

Comments
 (0)