diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 2421cfdca1..69ad5d8188 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -10,6 +10,7 @@ Release with new features and bugfixes: * https://github.com/devonfw/IDEasy/issues/2039[#2039]: IDE logo not shown in mac task bar * https://github.com/devonfw/IDEasy/issues/2176[#2176]: Support 7z archive extraction * https://github.com/devonfw/IDEasy/issues/2100[#2100]: Fix Python not available for Mac x64 +* https://github.com/devonfw/IDEasy/issues/788[#788]: Add support for IDE_OPTIONS variable per IDE commandlet * https://github.com/devonfw/IDEasy/issues/2224[#2224]: Brew upgrade ideasy not working * https://github.com/devonfw/IDEasy/issues/1784[#1784]: GUI now supports displaying progress bars * https://github.com/devonfw/IDEasy/issues/1917[#1917]: Allow the creation of a desktop shortcut for the GUI 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 b6da5b4cbb..9f2238516a 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,7 +2,9 @@ import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Set; import org.slf4j.Logger; @@ -29,6 +31,8 @@ public abstract class IdeToolCommandlet extends PluginBasedCommandlet { private static final Logger LOG = LoggerFactory.getLogger(IdeToolCommandlet.class); + private static final String OPTIONS_ENV_SUFFIX = "_OPTIONS"; + /** * The constructor. * @@ -60,7 +64,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 = getName().toUpperCase(Locale.ROOT).replace("-", "_") + 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/main/java/com/devonfw/tools/ide/variable/IdeVariables.java b/cli/src/main/java/com/devonfw/tools/ide/variable/IdeVariables.java index 83809e1a2b..6d8aab0b34 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/variable/IdeVariables.java +++ b/cli/src/main/java/com/devonfw/tools/ide/variable/IdeVariables.java @@ -126,6 +126,21 @@ public interface IdeVariables { /** {@link VariableDefinition} for support of overriding the default pycharm jvm options. */ VariableDefinitionString PYCHARM_VM_ARGS = new VariableDefinitionString("PYCHARM_VM_ARGS", null); + /** {@link VariableDefinition} for additional command-line arguments to start eclipse. */ + VariableDefinitionString ECLIPSE_OPTIONS = new VariableDefinitionString("ECLIPSE_OPTIONS", null); + + /** {@link VariableDefinition} for additional command-line arguments to start intellij. */ + VariableDefinitionString INTELLIJ_OPTIONS = new VariableDefinitionString("INTELLIJ_OPTIONS", null); + + /** {@link VariableDefinition} for additional command-line arguments to start android studio. */ + VariableDefinitionString ANDROID_STUDIO_OPTIONS = new VariableDefinitionString("ANDROID_STUDIO_OPTIONS", null); + + /** {@link VariableDefinition} for additional command-line arguments to start pycharm. */ + VariableDefinitionString PYCHARM_OPTIONS = new VariableDefinitionString("PYCHARM_OPTIONS", null); + + /** {@link VariableDefinition} for additional command-line arguments to start vscode. */ + VariableDefinitionString VSCODE_OPTIONS = new VariableDefinitionString("VSCODE_OPTIONS", null); + /** A {@link Collection} with all pre-defined {@link VariableDefinition}s. */ Collection> VARIABLES = List.of(PATH, HOME, WORKSPACE_PATH, IDE_HOME, IDE_ROOT, WORKSPACE, IDE_TOOLS, HTTP_VERSIONS, CREATE_START_SCRIPTS, @@ -133,6 +148,7 @@ public interface IdeVariables { GRADLE_USER_HOME, YARN_BUILD_OPTS, JASYPT_OPTS, MAVEN_ARGS, INTELLIJ_VM_ARGS, ANDROID_STUDIO_VM_ARGS, PYCHARM_VM_ARGS, + ECLIPSE_OPTIONS, INTELLIJ_OPTIONS, ANDROID_STUDIO_OPTIONS, PYCHARM_OPTIONS, VSCODE_OPTIONS, PROJECT_NAME, IDE_VARIABLE_SYNTAX_LEGACY_SUPPORT_ENABLED, PREFERRED_GIT_PROTOCOL); /** 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 b742c43b7e..61e47f8fa6 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 @@ -49,7 +49,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 6bb4b2b706..0ed72caad2 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 @@ -100,7 +100,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..170c3388b2 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 dd0b997413..3dba41b849 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.