diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/InstallPluginCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/InstallPluginCommandlet.java index af0328cca..26299b8f5 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/InstallPluginCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/InstallPluginCommandlet.java @@ -44,7 +44,7 @@ public void run() { String plugin = this.plugin.getValue(); if (commandlet instanceof PluginBasedCommandlet cmd) { - cmd.installPlugin(cmd.getPlugin(plugin)); + cmd.installPlugin(cmd.getPlugin(plugin), this.context.getCurrentStep()); } else { context.warning("Tool {} does not support installation of plugins.", commandlet.getName()); } diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/eclipse/Eclipse.java b/cli/src/main/java/com/devonfw/tools/ide/tool/eclipse/Eclipse.java index 9c88b65ed..4fb283c16 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/eclipse/Eclipse.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/eclipse/Eclipse.java @@ -16,6 +16,7 @@ import com.devonfw.tools.ide.process.ProcessErrorHandling; import com.devonfw.tools.ide.process.ProcessMode; import com.devonfw.tools.ide.process.ProcessResult; +import com.devonfw.tools.ide.step.Step; import com.devonfw.tools.ide.tool.ide.IdeToolCommandlet; import com.devonfw.tools.ide.tool.java.Java; import com.devonfw.tools.ide.tool.plugin.ToolPluginDescriptor; @@ -38,10 +39,11 @@ public Eclipse(IdeContext context) { @Override protected void configureToolBinary(ProcessContext pc, ProcessMode processMode, ProcessErrorHandling errorHandling) { - if (processMode == ProcessMode.DEFAULT_CAPTURE) { - + if ((processMode == ProcessMode.DEFAULT_CAPTURE) && this.context.getSystemInfo().isWindows()) { + pc.executable(Path.of("eclipsec")); + } else { + super.configureToolBinary(pc, processMode, errorHandling); } - super.configureToolBinary(pc, processMode, errorHandling); } @Override @@ -71,44 +73,11 @@ protected void installDependencies() { getCommandlet(Java.class).install(); } - /** - * Runs eclipse application. - * - * @param processMode - the {@link ProcessMode}. - * @param args the individual arguments to pass to eclipse. - * @return the {@link ProcessResult}. - */ - protected ProcessResult runEclipse(ProcessMode processMode, String... args) { - - Path toolPath = Path.of(getBinaryName()); - ProcessContext pc = this.context.newProcess(); - if (processMode == ProcessMode.DEFAULT_CAPTURE) { - pc.errorHandling(ProcessErrorHandling.LOG_ERROR); - } - pc.executable(toolPath); - Path configurationPath = getPluginsInstallationPath().resolve("configuration"); - this.context.getFileAccess().mkdirs(configurationPath); - pc.addArg("-data").addArg(this.context.getWorkspacePath()); - pc.addArg("-clean"); - pc.addArg("-keyring").addArg(this.context.getUserHome().resolve(".eclipse").resolve(".keyring")); - pc.addArg("-configuration").addArg(configurationPath); - if (processMode == ProcessMode.DEFAULT_CAPTURE) { - pc.addArg("-consoleLog").addArg("-nosplash"); - } - // TODO ability to use different Java version - Path javaPath = getCommandlet(Java.class).getToolBinPath(); - pc.addArg("-vm").addArg(javaPath); - pc.addArgs(args); - - return pc.run(processMode); - - } - @Override - public void installPlugin(ToolPluginDescriptor plugin) { + public void installPlugin(ToolPluginDescriptor plugin, Step step) { - ProcessResult result = runEclipse(ProcessMode.DEFAULT_CAPTURE, "-application", "org.eclipse.equinox.p2.director", "-repository", plugin.url(), - "-installIU", plugin.id()); + ProcessResult result = runTool(ProcessMode.DEFAULT_CAPTURE, null, ProcessErrorHandling.LOG_WARNING, "-application", "org.eclipse.equinox.p2.director", + "-repository", plugin.url(), "-installIU", plugin.id()); if (result.isSuccessful()) { for (String line : result.getOut()) { if (line.contains("Overall install request is satisfiable")) { @@ -117,7 +86,7 @@ public void installPlugin(ToolPluginDescriptor plugin) { } } this.context.error("Failed to install plugin {} ({}): exit code was {}", plugin.name(), plugin.id(), result.getExitCode()); - log(IdeLogLevel.WARNING, result.getOut()); + log(IdeLogLevel.DEBUG, result.getOut()); log(IdeLogLevel.ERROR, result.getErr()); } diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeaBasedIdeToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeaBasedIdeToolCommandlet.java index 24169d2c8..4fb7aa0dc 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeaBasedIdeToolCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeaBasedIdeToolCommandlet.java @@ -42,16 +42,14 @@ protected void configureToolArgs(ProcessContext pc, ProcessMode processMode, Pro } @Override - public void installPlugin(ToolPluginDescriptor plugin) { + public void installPlugin(ToolPluginDescriptor plugin, Step step) { String downloadUrl = getDownloadUrl(plugin); String pluginId = plugin.id(); Path tmpDir = null; - Step step = this.context.newStep("Install plugin: " + pluginId); try { - Path installationPath = this.getPluginsInstallationPath(); ensureInstallationPathExists(installationPath); @@ -62,7 +60,6 @@ public void installPlugin(ToolPluginDescriptor plugin) { extractDownloadedPlugin(fileAccess, downloadedFile, pluginId); step.success(); - } catch (IOException e) { step.error(e); throw new IllegalStateException("Failed to process installation of plugin: " + pluginId, e); @@ -70,7 +67,6 @@ public void installPlugin(ToolPluginDescriptor plugin) { if (tmpDir != null) { context.getFileAccess().delete(tmpDir); } - step.close(); } } diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/mvn/Mvn.java b/cli/src/main/java/com/devonfw/tools/ide/tool/mvn/Mvn.java index df48c6d2d..5505fbdce 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/mvn/Mvn.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/mvn/Mvn.java @@ -183,7 +183,7 @@ private Set findVariables(String content) { } @Override - public void installPlugin(ToolPluginDescriptor plugin) { + public void installPlugin(ToolPluginDescriptor plugin, Step step) { Path mavenPlugin = this.getToolPath().resolve("lib/ext/" + plugin.name() + ".jar"); this.context.getFileAccess().download(plugin.url(), mavenPlugin); diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/plugin/PluginBasedCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/plugin/PluginBasedCommandlet.java index d799b4737..f91ced525 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/plugin/PluginBasedCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/plugin/PluginBasedCommandlet.java @@ -10,6 +10,7 @@ import com.devonfw.tools.ide.common.Tag; import com.devonfw.tools.ide.context.IdeContext; import com.devonfw.tools.ide.io.FileAccess; +import com.devonfw.tools.ide.step.Step; import com.devonfw.tools.ide.tool.LocalToolCommandlet; import com.devonfw.tools.ide.tool.ide.IdeToolCommandlet; @@ -113,7 +114,9 @@ protected void postInstall(boolean newlyInstalled) { protected void installPlugins(Collection plugins) { for (ToolPluginDescriptor plugin : plugins) { if (plugin.active()) { - installPlugin(plugin); + try (Step step = this.context.newStep("Install plugin " + plugin.name())) { + installPlugin(plugin, step); + } } else { handleInstall4InactivePlugin(plugin); } @@ -122,8 +125,9 @@ protected void installPlugins(Collection plugins) { /** * @param plugin the {@link ToolPluginDescriptor} to install. + * @param step the {@link Step} for the plugin installation. */ - public abstract void installPlugin(ToolPluginDescriptor plugin); + public abstract void installPlugin(ToolPluginDescriptor plugin, Step step); /** * @param plugin the {@link ToolPluginDescriptor} to uninstall. diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/vscode/Vscode.java b/cli/src/main/java/com/devonfw/tools/ide/tool/vscode/Vscode.java index 06aa40a3d..e6a7cfc9b 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/vscode/Vscode.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/vscode/Vscode.java @@ -17,6 +17,7 @@ import com.devonfw.tools.ide.process.ProcessContext; import com.devonfw.tools.ide.process.ProcessErrorHandling; import com.devonfw.tools.ide.process.ProcessMode; +import com.devonfw.tools.ide.step.Step; import com.devonfw.tools.ide.tool.ToolCommandlet; import com.devonfw.tools.ide.tool.ide.IdeToolCommandlet; import com.devonfw.tools.ide.tool.plugin.ToolPluginDescriptor; @@ -44,8 +45,10 @@ protected String getBinaryName() { } @Override - public void installPlugin(ToolPluginDescriptor plugin) { - throw new IllegalStateException(); // method not used + public void installPlugin(ToolPluginDescriptor plugin, Step step) { + + doInstallPlugins(List.of(plugin)); + step.success(); } @Override diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/androidstudio/AndroidStudioTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/androidstudio/AndroidStudioTest.java index d50fe9ec9..a56f3eacc 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/tool/androidstudio/AndroidStudioTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/androidstudio/AndroidStudioTest.java @@ -80,8 +80,8 @@ public void testAndroidStudioRun(String os, WireMockRuntimeInfo wmRuntimeInfo) t private void checkInstallation(IdeTestContext context) { // commandlet - android-studio assertThat(context.getSoftwarePath().resolve("android-studio/.ide.software.version")).exists().hasContent("2024.1.1.1"); - assertThat(context).logAtSuccess().hasMessage("Successfully installed android-studio in version 2024.1.1.1"); - assertThat(context).logAtSuccess().hasMessageContaining("Install plugin: mockedPlugin"); + assertThat(context).logAtSuccess().hasEntries("Successfully ended step 'Install plugin MockedPlugin'.", // + "Successfully installed android-studio in version 2024.1.1.1"); assertThat(context.getPluginsPath().resolve("android-studio").resolve("mockedPlugin").resolve("MockedClass.class")).exists(); } diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/intellij/IntellijTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/intellij/IntellijTest.java index aff2cddaa..56bca6247 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/tool/intellij/IntellijTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/intellij/IntellijTest.java @@ -76,7 +76,7 @@ public void testIntellijInstallPluginAfterwards(String os, WireMockRuntimeInfo w // act commandlet.install(); - commandlet.installPlugin(commandlet.getPlugins().getById("mockedPlugin")); + commandlet.installPlugin(commandlet.getPlugins().getById("mockedPlugin"), this.context.newStep("Install plugin MockedPlugin")); // assert checkInstallation(this.context); @@ -142,8 +142,8 @@ private void checkInstallation(IdeTestContext context) { assertThat(context.getSoftwarePath().resolve("intellij/.ide.software.version")).exists().hasContent("2023.3.3"); assertThat(context).logAtSuccess().hasEntries("Successfully installed java in version 17.0.10_7", - "Successfully ended step 'Install plugin: mockedPlugin'.", "Successfully installed intellij in version 2023.3.3"); + assertThat(context).logAtSuccess().hasMessage("Successfully ended step 'Install plugin MockedPlugin'."); assertThat(context.getPluginsPath().resolve("intellij").resolve("mockedPlugin").resolve("MockedClass.class")).exists(); } diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/plugin/ExamplePluginBasedCommandlet.java b/cli/src/test/java/com/devonfw/tools/ide/tool/plugin/ExamplePluginBasedCommandlet.java index fc7d62e9a..92b0b9120 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/tool/plugin/ExamplePluginBasedCommandlet.java +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/plugin/ExamplePluginBasedCommandlet.java @@ -4,6 +4,7 @@ import com.devonfw.tools.ide.common.Tag; import com.devonfw.tools.ide.context.IdeContext; +import com.devonfw.tools.ide.step.Step; /** * Example implementation of {@link PluginBasedCommandlet} for testing. @@ -23,7 +24,7 @@ public ExamplePluginBasedCommandlet(IdeContext context, String tool, Set ta } @Override - public void installPlugin(ToolPluginDescriptor plugin) { + public void installPlugin(ToolPluginDescriptor plugin, Step step) { } }