diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 0d0af98457..0660ad52b6 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/788[#788]: Add support for IDE_OPTIONS variable per IDE commandlet * https://github.com/devonfw/IDEasy/issues/2313[#2313]: Fix python installation failing with wired behaviour * https://github.com/devonfw/IDEasy/issues/2168[#2168]: Add support for git_remote property to configure additional remotes after cloning * https://github.com/devonfw/IDEasy/issues/1676[#1676]: Import extra sdks automatically into ide diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java index 2a82fb45dc..f30f44b851 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java @@ -2,6 +2,7 @@ import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -16,6 +17,7 @@ import com.devonfw.tools.ide.common.Tag; import com.devonfw.tools.ide.context.IdeContext; import com.devonfw.tools.ide.environment.AbstractEnvironmentVariables; +import com.devonfw.tools.ide.environment.EnvironmentVariables; import com.devonfw.tools.ide.environment.ExtensibleEnvironmentVariables; import com.devonfw.tools.ide.io.FileAccess; import com.devonfw.tools.ide.log.IdeLogLevel; @@ -42,6 +44,7 @@ public abstract class IdeToolCommandlet extends PluginBasedCommandlet { private static final Logger LOG = LoggerFactory.getLogger(IdeToolCommandlet.class); + private static final String OPTIONS_ENV_SUFFIX = "_OPTIONS"; private final Map> extraSdkMap; /** @@ -76,7 +79,26 @@ protected final void doRun() { @Override public ProcessResult runTool(List args) { - return runTool(ProcessMode.BACKGROUND, null, args); + List effectiveArgs = new ArrayList<>(args); + addIdeOptions(effectiveArgs); + return runTool(ProcessMode.BACKGROUND, null, effectiveArgs); + } + + /** + * Appends the tokens of {@code «IDE»_OPTIONS} (e.g. {@code INTELLIJ_OPTIONS}) to the given {@code args}. This is the per-tool analogue of the global + * {@code IDE_OPTIONS} and only applies when actually starting the IDE (not for internal calls like plugin installation or repository import). + * + * @param args the command-line arguments to launch this IDE, extended in place. + */ + private void addIdeOptions(List args) { + + String variableName = EnvironmentVariables.getToolVariablePrefix(this.tool) + OPTIONS_ENV_SUFFIX; + String options = this.context.getVariables().get(variableName); + if ((options != null) && !options.isBlank()) { + for (String option : options.trim().split("\\s+")) { + args.add(option); + } + } } @Override diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/eclipse/EclipseTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/eclipse/EclipseTest.java index b79f0b239e..a7e5069741 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/tool/eclipse/EclipseTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/eclipse/EclipseTest.java @@ -53,7 +53,8 @@ void testEclipse(String os) throws IOException { assertThat(context.getPluginsPath().resolve("eclipse")).isDirectory(); assertThat(eclipse.getToolBinPath().resolve("eclipsetest")).hasContent( "eclipse " + os + " -data " + context.getWorkspacePath() + " -keyring " + context.getUserHome().resolve(".eclipse").resolve(".keyring") - + " -configuration " + context.getPluginsPath().resolve("eclipse").resolve("configuration") + " gui -showlocation eclipseproject"); + + " -configuration " + context.getPluginsPath().resolve("eclipse").resolve("configuration") + + " gui -showlocation eclipseproject -nosplash"); //if tool already installed eclipse.install(); 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 c60accbf0a..1bdcaca3bb 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 @@ -103,7 +103,7 @@ void testIntellijRun(String os) { // assert checkInstallation(this.context); assertThat(commandlet.getToolBinPath().resolve("intellijtest")).hasContent( - "intellij " + this.context.getSystemInfo().getOs() + " " + this.context.getWorkspacePath()); + "intellij " + this.context.getSystemInfo().getOs() + " nosplash " + this.context.getWorkspacePath()); } /** diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/vscode/VscodeTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/vscode/VscodeTest.java index e98045bbb7..72e57032a0 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/tool/vscode/VscodeTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/vscode/VscodeTest.java @@ -12,6 +12,7 @@ import com.devonfw.tools.ide.context.AbstractIdeContextTest; import com.devonfw.tools.ide.context.IdeTestContext; import com.devonfw.tools.ide.context.ProcessContextTestImpl; +import com.devonfw.tools.ide.environment.EnvironmentVariablesType; import com.devonfw.tools.ide.os.SystemInfoMock; import com.devonfw.tools.ide.process.ProcessContext; import com.devonfw.tools.ide.process.ProcessMode; @@ -151,6 +152,23 @@ void testConfigureToolArgsDoesNotSetWslEnvVarOnNonWsl() { assertThat(pc.getEnvVar("DONT_PROMPT_WSL_INSTALL")).isNull(); } + /** + * Tests that {@code VSCODE_OPTIONS} is honoured by appending its tokens as additional command-line arguments when starting the IDE (analogue to the + * global {@code IDE_OPTIONS} used for IDEasy itself, see issue #788). + */ + @Test + void testRunAddsVscodeOptions() { + + // arrange + IdeTestContext context = newContext(PROJECT_VSCODE); + context.getVariables().getByType(EnvironmentVariablesType.CONF).set("VSCODE_OPTIONS", "--wait --new-window"); + CapturingVscode commandlet = new CapturingVscode(context); + // act + commandlet.run(); + // assert + assertThat(commandlet.lastArgs).contains("--wait", "--new-window"); + } + @Test void testVscodiumInstall() { diff --git a/cli/src/test/resources/ide-projects/eclipse/eclipseproject/conf/ide.properties b/cli/src/test/resources/ide-projects/eclipse/eclipseproject/conf/ide.properties index 2218e250c7..47c31cb084 100644 --- a/cli/src/test/resources/ide-projects/eclipse/eclipseproject/conf/ide.properties +++ b/cli/src/test/resources/ide-projects/eclipse/eclipseproject/conf/ide.properties @@ -1 +1,2 @@ M2_REPO=~/.m2/repository +ECLIPSE_OPTIONS=-nosplash diff --git a/cli/src/test/resources/ide-projects/intellij/project/conf/ide.properties b/cli/src/test/resources/ide-projects/intellij/project/conf/ide.properties index 8543c71b51..ce5c756dff 100644 --- a/cli/src/test/resources/ide-projects/intellij/project/conf/ide.properties +++ b/cli/src/test/resources/ide-projects/intellij/project/conf/ide.properties @@ -1,2 +1,3 @@ # here the INTELLIJ_PROPERTIES variable should be added by the test INTELLIJ_VM_ARGS=-Xms256m -Xmx4096m -XX:ReservedCodeCacheSize=256m -Dsun.io.useCanonCaches=true -ea +INTELLIJ_OPTIONS=nosplash diff --git a/documentation/variables.adoc b/documentation/variables.adoc index 681aa99fa7..87233b8320 100644 --- a/documentation/variables.adoc +++ b/documentation/variables.adoc @@ -17,6 +17,7 @@ See also link:https://github.com/devonfw/IDEasy/blob/main/cli/src/main/java/com/ |`IDE_ROOT`|e.g. `~/projects/` or `C:\projects`|The installation root directory of `IDEasy` - see link:structure.adoc[structure] for details. |`IDE_HOME`|e.g. `/projects/my-project`|The top level directory of your `IDEasy` project. |`IDE_OPTIONS`|e.g. `-Dhttps.proxyUser=$USERNAME -Dhttps.proxyPassword=«password»`|General options that will be applied to each call of `IDEasy`. Should typically be used for JVM options like link:proxy-support.adoc[proxy-support]. +|`«IDE»_OPTIONS`|e.g. `nosplash` (for `INTELLIJ_OPTIONS`)|Additional command-line arguments passed when starting the IDE `«IDE»` (e.g. `ECLIPSE_OPTIONS`, `INTELLIJ_OPTIONS`, `ANDROID_STUDIO_OPTIONS`, `PYCHARM_OPTIONS`, or `VSCODE_OPTIONS`). Analogous to the global `IDE_OPTIONS` but specific to a single IDE. |*`PATH`*|`$IDE_HOME/software/«tool»:...:$PATH`|Your system path is adjusted by `ide` link:cli.adoc[command]. |`BASH_PATH`|e.g. `C:\Program Files\Git\usr\bin\bash.exe`|Absolute path to your bash. Only used as fallback on Windows if bash could not be found from registry. |`IDE_TOOLS`|`(java mvn node npm)`|List of tools that should be installed by default on project creation.