diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 5cdca1a21..4775e5a2e 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -6,6 +6,7 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE Release with new features and bugfixes: +* https://github.com/devonfw/IDEasy/issues/628[#638]: Fixed update fails on first error * https://github.com/devonfw/IDEasy/issues/553[#554]: Missmatch of IDE_ROOT * https://github.com/devonfw/IDEasy/issues/556[#556]: ProcessContext should compute PATH on run and not in constructor * https://github.com/devonfw/IDEasy/issues/557[#557]: Failed to update tomcat: Cannot find a (Map) Key deserializer for type VersionRange diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/AbstractUpdateCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/AbstractUpdateCommandlet.java index e5e56c24e..83cbeebe2 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/AbstractUpdateCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/AbstractUpdateCommandlet.java @@ -66,12 +66,9 @@ private void updateConf() { } } - Step step = this.context.newStep("Copy configuration templates", templatesFolder); - try { + try (Step step = this.context.newStep("Copy configuration templates", templatesFolder)) { setupConf(templatesFolder, this.context.getIdeHome()); step.success(); - } finally { - step.close(); } } @@ -137,14 +134,13 @@ private void updateSettings() { private void updateSoftware() { - Step step = this.context.newStep("Install or update software"); - try { + try (Step step = this.context.newStep("Install or update software")) { Set toolCommandlets = new HashSet<>(); // installed tools in IDE_HOME/software - List softwares = this.context.getFileAccess().listChildren(this.context.getSoftwarePath(), Files::isDirectory); - for (Path software : softwares) { - String toolName = software.getFileName().toString(); + List softwarePaths = this.context.getFileAccess().listChildren(this.context.getSoftwarePath(), Files::isDirectory); + for (Path softwarePath : softwarePaths) { + String toolName = softwarePath.getFileName().toString(); ToolCommandlet toolCommandlet = this.context.getCommandletManager().getToolCommandletOrNull(toolName); if (toolCommandlet != null) { toolCommandlets.add(toolCommandlet); @@ -167,11 +163,14 @@ private void updateSoftware() { // update/install the toolCommandlets for (ToolCommandlet toolCommandlet : toolCommandlets) { - toolCommandlet.install(false); + try { + toolCommandlet.install(false); + } catch (Exception e) { + step.error(e, "Installation of {} failed!", toolCommandlet.getName()); + } + } step.success(); - } finally { - step.close(); } } diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/UpdateCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/UpdateCommandletTest.java index f9407a633..6c3746a30 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/commandlet/UpdateCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/UpdateCommandletTest.java @@ -56,4 +56,30 @@ private void deleteTemplatesFolder(IdeContext context) throws IOException { Files.delete(templates.getParent()); Files.delete(templates.getParent().getParent()); } + + /** + * Tests if a sub step (installation of software) of update failed, the overall update process will not fail too. + *

+ * See: #628 for reference. + */ + @Test + public void testRunUpdateSoftwareDoesNotFailOnFailedSoftwareInstallations() { + + // arrange + IdeTestContext context = newContext(PROJECT_UPDATE); + Path javaRepository = context.getToolRepositoryPath().resolve("default").resolve("java"); + context.getFileAccess().delete(javaRepository); + Path javaDownload = context.getIdeRoot().resolve("repository").resolve("java"); + context.getFileAccess().delete(javaDownload); + UpdateCommandlet uc = context.getCommandletManager().getCommandlet(UpdateCommandlet.class); + + // act + uc.run(); + + // assert + assertThat(context).logAtError().hasMessage("Installation of java failed!"); + assertThat(context).logAtError().hasMessage("Installation of mvn failed!"); + assertThat(context).logAtSuccess().hasMessage("Successfully updated settings repository."); + assertThat(context).logAtSuccess().hasMessage("Install or update software"); + } } diff --git a/cli/src/test/resources/ide-projects/update/repository/java/java/default/bin/java b/cli/src/test/resources/ide-projects/update/repository/java/java/default/bin/java new file mode 100644 index 000000000..bb96ab46f --- /dev/null +++ b/cli/src/test/resources/ide-projects/update/repository/java/java/default/bin/java @@ -0,0 +1,2 @@ +#!/bin/bash +echo java $* diff --git a/cli/src/test/resources/ide-projects/update/repository/mvn/mvn/default/bin/mvn b/cli/src/test/resources/ide-projects/update/repository/mvn/mvn/default/bin/mvn new file mode 100644 index 000000000..1b4a9986e --- /dev/null +++ b/cli/src/test/resources/ide-projects/update/repository/mvn/mvn/default/bin/mvn @@ -0,0 +1,2 @@ +#!/bin/bash +echo "mvn $*"