diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 918ac0f87e..b96dad3631 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/1987[#1987]: Fixed issue that the GUI would not launch in SNAPSHOT versions. Added -l flag to allow extended logging for the GUI. The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/47?closed=1[milestone 2026.07.002]. diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/gui/Gui.java b/cli/src/main/java/com/devonfw/tools/ide/tool/gui/Gui.java index 01ab0ab3c1..8982784554 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/gui/Gui.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/gui/Gui.java @@ -11,8 +11,8 @@ import com.devonfw.tools.ide.commandlet.Commandlet; import com.devonfw.tools.ide.context.IdeContext; import com.devonfw.tools.ide.process.ProcessContext; -import com.devonfw.tools.ide.process.ProcessContextImpl; import com.devonfw.tools.ide.process.ProcessMode; +import com.devonfw.tools.ide.property.FlagProperty; import com.devonfw.tools.ide.tool.ToolEditionAndVersion; import com.devonfw.tools.ide.tool.ToolInstallRequest; import com.devonfw.tools.ide.tool.ToolInstallation; @@ -27,6 +27,8 @@ public class Gui extends Commandlet { private static final Logger LOG = LoggerFactory.getLogger(Gui.class); + final FlagProperty enableExtendedLogging; + /** * @param context the {@link IdeContext}. */ @@ -34,6 +36,7 @@ public Gui(IdeContext context) { super(context); addKeyword(getName()); + enableExtendedLogging = add(new FlagProperty("--enableLogging", false, "-l")); } @Override @@ -45,7 +48,7 @@ public String getName() { @Override protected void doRun() { - ProcessContext processContext = new ProcessContextImpl(this.context); + ProcessContext processContext = context.newProcess(); Java java = this.context.getCommandletManager().getCommandlet(Java.class); Mvn mvn = this.context.getCommandletManager().getCommandlet(Mvn.class); @@ -58,9 +61,16 @@ protected void doRun() { new ToolEditionAndVersion(VersionIdentifier.of("25.*")) ); - mvn.installTool(mavenToolInstallRequest); + ToolInstallation mvnToolInstallation = mvn.installTool(mavenToolInstallRequest); ToolInstallation javaInstallation = java.installTool(javaToolInstallRequest); + /* Register the freshly installed mvn on the IDEasy managed PATH so that the IDEasy controlled maven is used to launch + the GUI instead of any maven that happens to be on the system PATH. We install via installTool (software repository + only) and therefore have to register the bin directory ourselves (install() would normally do this). I tried to achieve this alternatively via .withPathEntry(), however, this did not work as expected. + This was tested on a Mac; potentially, withPathVariable() works correctly on Windows. + */ + context.getPath().setPath(mvn.getName(), mvnToolInstallation.binDir()); + LOG.debug("Starting GUI via commandlet"); Path pomPath = context.getIdeInstallationPath().resolve("gui/pom.xml"); @@ -69,9 +79,10 @@ protected void doRun() { } List args = List.of( - "-f", + "-U", //required for latest snapshot versions + "-f", //use specified POM file pomPath.toString(), - "exec:exec", + "org.codehaus.mojo:exec-maven-plugin:3.1.0:exec", "-Dexec.executable=java", "-Dexec.classpathScope=compile", "-Dexec.args=-classpath %classpath com.devonfw.ide.gui.AppLauncher" @@ -81,6 +92,13 @@ protected void doRun() { * We manually update the PATH entry with our java version, as by default IDEasy includes the SymLink under /projectname/software/java/bin in the PATH * In case of projects using older Java Versions, this is important as the java version of the project could potentially older. */ - mvn.runTool(processContext.withPathEntry(javaInstallation.binDir()), ProcessMode.BACKGROUND_SILENT, args); + ProcessMode processMode = this.enableExtendedLogging.isTrue() ? ProcessMode.DEFAULT : ProcessMode.BACKGROUND_SILENT; + try { + mvn.runTool(processContext.withPathEntry(javaInstallation.binDir()), processMode, args); + } catch (Exception e) { + LOG.error( + "Failed to launch the GUI. If maven states issues with dependency resolution, check whether the maven M2 repo is enabled in your project.", + e); + } } } diff --git a/cli/src/main/package/gui/pom.xml b/cli/src/main/package/gui/pom.xml index d7d054450c..bc2d95e157 100644 --- a/cli/src/main/package/gui/pom.xml +++ b/cli/src/main/package/gui/pom.xml @@ -4,6 +4,21 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + + + ossrh + OSSRH Snapshots + https://central.sonatype.com/repository/maven-snapshots + + true + + + false + + + + com.devonfw.tools.IDEasy ide-gui-launcher $[project.version] @@ -17,5 +32,4 @@ $[project.version] - diff --git a/cli/src/main/resources/nls/Help.properties b/cli/src/main/resources/nls/Help.properties index 1e52f11056..2d56efe2c1 100644 --- a/cli/src/main/resources/nls/Help.properties +++ b/cli/src/main/resources/nls/Help.properties @@ -52,6 +52,7 @@ cmd.gradle=Tool commandlet for Gradle (Build-Tool). cmd.gradle.detail=Gradle is a build automation tool for Java, Kotlin, and other JVM-based languages. Detailed documentation can be found at https://docs.gradle.org/ cmd.gui=Tool commandlet for running the IDEasy GUI cmd.gui.detail=This command will run the GUI version of IDEasy, opening up a more comprehensible project dashboard and allowing for easier management of your local IDEasy instance. +cmd.gui.opt.--enableLogging=Run the GUI with enabled logging to the terminal. cmd.helm=Tool commandlet for Helm (Kubernetes Package Manager). cmd.helm.detail=Helm is a package manager for Kubernetes that simplifies deploying and managing applications. Detailed documentation can be found at https://helm.sh/docs/ cmd.help=Prints this help. diff --git a/cli/src/main/resources/nls/Help_de.properties b/cli/src/main/resources/nls/Help_de.properties index 3c4f9787cf..fc059d47e2 100644 --- a/cli/src/main/resources/nls/Help_de.properties +++ b/cli/src/main/resources/nls/Help_de.properties @@ -52,6 +52,7 @@ cmd.gradle=Werkzeug Kommando für Gradle (Build-Tool). cmd.gradle.detail=Gradle ist ein Build-Automatisierungstool für Java, Kotlin und andere JVM-basierte Sprachen. Detaillierte Dokumentation ist zu finden unter https://docs.gradle.org/ cmd.gui=Werkzeug Kommando, um die GUI von IDEasy zu öffnen. cmd.gui.detail=Dieser Befehl startet die GUI-Version von IDEasy, öffnet ein übersichtlicheres Projekt-Dashboard und erleichtert die Verwaltung Ihrer lokalen IDEasy-Instanz. +cmd.gui.opt.--enableLogging=Führe die GUI mit aktiviertem Debug-Logging auf das Terminal aus. cmd.helm=Werkzeug Kommando für Helm (Kubernetes Package Manager). cmd.helm.detail=Helm ist ein Paketmanager für Kubernetes, der das Bereitstellen und Verwalten von Anwendungen vereinfacht. Detaillierte Dokumentation ist zu finden unter https://helm.sh/docs/ cmd.help=Zeigt diese Hilfe an. diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/gui/GuiTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/gui/GuiTest.java new file mode 100644 index 0000000000..fe2b83b324 --- /dev/null +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/gui/GuiTest.java @@ -0,0 +1,45 @@ +package com.devonfw.tools.ide.tool.gui; + +import org.junit.jupiter.api.Test; + +import com.devonfw.tools.ide.context.AbstractIdeContextTest; +import com.devonfw.tools.ide.context.IdeTestContext; +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; +import com.github.tomakehurst.wiremock.junit5.WireMockTest; + +/** + * Tests for {@link Gui}. + */ +@WireMockTest +class GuiTest extends AbstractIdeContextTest { + + private static final String PROJECT_GUI = "gui"; + + @Test + void testEnableLoggingUsesDefaultProcessMode(WireMockRuntimeInfo wmRuntimeInfo) { + // arrange + IdeTestContext context = newContext(PROJECT_GUI, wmRuntimeInfo); + Gui gui = new Gui(context); + gui.enableExtendedLogging.setValue(true); + + // act + gui.run(); + + // assert: with ProcessMode.DEFAULT, process output is captured as INFO log + assertThat(context).logAtInfo().hasMessage("Scanning for projects..."); + } + + @Test + void testDisabledLoggingUsesBackgroundSilentMode(WireMockRuntimeInfo wmRuntimeInfo) { + // arrange + IdeTestContext context = newContext(PROJECT_GUI, wmRuntimeInfo); + Gui gui = new Gui(context); + // enableExtendedLogging is false by default → ProcessMode.BACKGROUND_SILENT + + // act + gui.run(); + + // assert: with ProcessMode.BACKGROUND_SILENT, process output is suppressed + assertThat(context).logAtInfo().hasNoMessage("Scanning for projects..."); + } +} diff --git a/cli/src/test/resources/ide-projects/gui/_ide/installation/gui/pom.xml b/cli/src/test/resources/ide-projects/gui/_ide/installation/gui/pom.xml new file mode 100644 index 0000000000..fb0563a2f3 --- /dev/null +++ b/cli/src/test/resources/ide-projects/gui/_ide/installation/gui/pom.xml @@ -0,0 +1 @@ + diff --git a/cli/src/test/resources/ide-projects/gui/_ide/urls/java/java/25.0.2/urls b/cli/src/test/resources/ide-projects/gui/_ide/urls/java/java/25.0.2/urls new file mode 100644 index 0000000000..7c8b743bb9 --- /dev/null +++ b/cli/src/test/resources/ide-projects/gui/_ide/urls/java/java/25.0.2/urls @@ -0,0 +1 @@ +${testbaseurl}/download/java/java/25.0.2/java-25.0.2.tgz diff --git a/cli/src/test/resources/ide-projects/gui/_ide/urls/mvn/mvn/3.9.0/urls b/cli/src/test/resources/ide-projects/gui/_ide/urls/mvn/mvn/3.9.0/urls new file mode 100644 index 0000000000..7b9b924496 --- /dev/null +++ b/cli/src/test/resources/ide-projects/gui/_ide/urls/mvn/mvn/3.9.0/urls @@ -0,0 +1 @@ +${testbaseurl}/download/mvn/mvn/3.9.0/mvn-3.9.0.tgz diff --git a/cli/src/test/resources/ide-projects/gui/project/home/.ide/ide.properties b/cli/src/test/resources/ide-projects/gui/project/home/.ide/ide.properties new file mode 100644 index 0000000000..bd7a0330f3 --- /dev/null +++ b/cli/src/test/resources/ide-projects/gui/project/home/.ide/ide.properties @@ -0,0 +1 @@ +MAVEN_VERSION=3.9.0 diff --git a/cli/src/test/resources/ide-projects/gui/project/settings/ide.properties b/cli/src/test/resources/ide-projects/gui/project/settings/ide.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cli/src/test/resources/ide-projects/gui/project/workspaces/main/.gitkeep b/cli/src/test/resources/ide-projects/gui/project/workspaces/main/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cli/src/test/resources/ide-projects/gui/repository/java/java/default/bin/java b/cli/src/test/resources/ide-projects/gui/repository/java/java/default/bin/java new file mode 100755 index 0000000000..bb96ab46f2 --- /dev/null +++ b/cli/src/test/resources/ide-projects/gui/repository/java/java/default/bin/java @@ -0,0 +1,2 @@ +#!/bin/bash +echo java $* diff --git a/cli/src/test/resources/ide-projects/gui/repository/mvn/mvn/default/bin/mvn b/cli/src/test/resources/ide-projects/gui/repository/mvn/mvn/default/bin/mvn new file mode 100755 index 0000000000..746f35445b --- /dev/null +++ b/cli/src/test/resources/ide-projects/gui/repository/mvn/mvn/default/bin/mvn @@ -0,0 +1,2 @@ +#!/bin/bash +echo "Scanning for projects..."