Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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/2286[#2286]: Fix SystemPath.findBinary to search extraPathEntries
* https://github.com/devonfw/IDEasy/issues/1165[#1165]: Fix automatic project import for Eclipse
* https://github.com/devonfw/IDEasy/issues/2040[#2040]: Fixed buggy workspace selection in the GUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
*
Expand Down Expand Up @@ -60,7 +64,26 @@ protected final void doRun() {
@Override
public ProcessResult runTool(List<String> args) {

return runTool(ProcessMode.BACKGROUND, null, args);
List<String> 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<String> args) {

String variableName = getName().toUpperCase(Locale.ROOT).replace("-", "_") + OPTIONS_ENV_SUFFIX;
Comment thread
Ali-Shariati-Najafabadi marked this conversation as resolved.
Outdated
String options = this.context.getVariables().get(variableName);
if ((options != null) && !options.isBlank()) {
for (String option : options.trim().split("\\s+")) {
args.add(option);
}
}
}

@Override
Expand Down
16 changes: 16 additions & 0 deletions cli/src/main/java/com/devonfw/tools/ide/variable/IdeVariables.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,29 @@ 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);

Comment thread
Ali-Shariati-Najafabadi marked this conversation as resolved.
Outdated
/** A {@link Collection} with all pre-defined {@link VariableDefinition}s. */
Collection<VariableDefinition<?>> VARIABLES = List.of(PATH, HOME, WORKSPACE_PATH, IDE_HOME, IDE_ROOT, WORKSPACE, IDE_TOOLS, HTTP_VERSIONS,
CREATE_START_SCRIPTS,
IDE_MIN_VERSION, MVN_VERSION, M2_REPO, DOCKER_EDITION, MVN_BUILD_OPTS, NPM_BUILD_OPTS, NPM_CONFIG_USERCONFIG, GRADLE_BUILD_OPTS,
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);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
M2_REPO=~/.m2/repository
ECLIPSE_OPTIONS=nosplash
Comment thread
Ali-Shariati-Najafabadi marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions documentation/variables.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down