From 449f505f9275f83994cd7816b794bd54b858a4ac Mon Sep 17 00:00:00 2001 From: ducminh02 Date: Thu, 9 Apr 2026 22:22:20 +0200 Subject: [PATCH 1/3] feat: implement environment commandlet to display and export IDE variables --- .../ide/commandlet/EnvironmentCommandlet.java | 14 +++---- .../tools/ide/context/AbstractIdeContext.java | 3 ++ .../EnvironmentCommandletGlobalTest.java | 41 +++++++++++++++++++ 3 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 cli/src/test/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandletGlobalTest.java diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandlet.java index 7a1df72be..3a2f98f12 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandlet.java @@ -1,5 +1,6 @@ package com.devonfw.tools.ide.commandlet; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -8,7 +9,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.devonfw.tools.ide.cli.CliExitException; import com.devonfw.tools.ide.context.AbstractIdeContext; import com.devonfw.tools.ide.context.IdeContext; import com.devonfw.tools.ide.environment.EnvironmentVariablesType; @@ -65,9 +65,6 @@ public boolean isProcessableOutput() { @Override protected void doRun() { - if (this.context.getIdeHome() == null) { - throw new CliExitException(); - } boolean winCmd = false; WindowsPathSyntax pathSyntax = null; @@ -84,9 +81,12 @@ protected void doRun() { List variables = this.context.getVariables().collectVariables(); Map variableMap = variables.stream().collect(Collectors.toMap(VariableLine::getName, v -> v)); - EnvironmentVariableCollectorContext environmentVariableCollectorContext = new EnvironmentVariableCollectorContext(variableMap, - new VariableSource(EnvironmentVariablesType.TOOL, this.context.getSoftwarePath()), pathSyntax); - setEnvironmentVariablesInLocalTools(environmentVariableCollectorContext); + Path softwarePath = this.context.getSoftwarePath(); + if (softwarePath != null) { + EnvironmentVariableCollectorContext environmentVariableCollectorContext = new EnvironmentVariableCollectorContext(variableMap, + new VariableSource(EnvironmentVariablesType.TOOL, softwarePath), pathSyntax); + setEnvironmentVariablesInLocalTools(environmentVariableCollectorContext); + } printLines(variableMap, winCmd); } diff --git a/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java b/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java index 75b6b0d72..a56ed5270 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java +++ b/cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java @@ -601,6 +601,9 @@ public Path getUserHome() { protected void setUserHome(Path userHome) { this.userHome = userHome; + this.userHomeIde = userHome.resolve(FOLDER_DOT_IDE); + this.downloadPath = userHome.resolve("Downloads/ide"); + this.variables = null; resetPrivacyMap(); } diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandletGlobalTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandletGlobalTest.java new file mode 100644 index 000000000..082c0cd9d --- /dev/null +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandletGlobalTest.java @@ -0,0 +1,41 @@ +package com.devonfw.tools.ide.commandlet; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import com.devonfw.tools.ide.context.AbstractIdeContextTest; +import com.devonfw.tools.ide.context.IdeTestContext; +import com.devonfw.tools.ide.log.IdeLogEntry; + +/** + * Test of {@link EnvironmentCommandlet} for global configuration. + */ +class EnvironmentCommandletGlobalTest extends AbstractIdeContextTest { + + @Test + void testRunOutsideProject(@TempDir Path tempDir) throws IOException { + + // arrange + Path userHome = tempDir.resolve("user"); + Path userHomeIde = userHome.resolve(".ide"); + Files.createDirectories(userHomeIde); + Files.writeString(userHomeIde.resolve("ide.properties"), "export FOO=bar\n"); + + IdeTestContext context = new IdeTestContext(tempDir.resolve("cwd"), null); + context.setUserHome(userHome); + + EnvironmentCommandlet env = context.getCommandletManager().getCommandlet(EnvironmentCommandlet.class); + + // act + env.run(); + + // assert + assertThat(context).log().hasEntries( // + IdeLogEntry.ofProcessable("export FOO=\"bar\"") // + ); + } +} From 6842d66c9cf38a7c8e4377783c7b21ecdfb48e12 Mon Sep 17 00:00:00 2001 From: ducminh02 Date: Fri, 10 Apr 2026 12:10:38 +0200 Subject: [PATCH 2/3] docs: add issue 1270 to changelog for global user settings support --- CHANGELOG.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index d5418bf2e..d1a2d914c 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -6,6 +6,8 @@ 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/1270[#1270]: IDEasy now loads global user settings if outside a project + The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/43?closed=1[milestone 2026.04.002]. == 2026.04.001 From 6015886518d6f1e8ab0e89ec1a7bc3bb706b5531 Mon Sep 17 00:00:00 2001 From: Minh Vu <101068929+ducminh02@users.noreply.github.com> Date: Fri, 10 Apr 2026 12:52:45 +0200 Subject: [PATCH 3/3] Update CHANGELOG.adoc --- CHANGELOG.adoc | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 9c32de344..dd88f1602 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -6,12 +6,9 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE Release with new features and bugfixes: -<<<<<<< fix/1270-load-global-user-settings-outside-project * https://github.com/devonfw/IDEasy/issues/1270[#1270]: IDEasy now loads global user settings if outside a project -======= * https://github.com/devonfw/IDEasy/issues/1552[#1552]: Add Commandlet to fix TLS issue * https://github.com/devonfw/IDEasy/issues/1760[#1760]: Accept empty input for single option ->>>>>>> main The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/43?closed=1[milestone 2026.04.002].