Closed hohwille closed 2 months ago
This bug is not specific for JAVA_VERSION
.
There is a severe design flaw in how we implemented CreateCommandlet
:
It creates the IdeContext
to run the command from the current project or with no custom variables if we are not inside an IDE project.
After cloning the settings, we need to create a new IdeContext
or more likely update the existing IdeContext
with the new cloned settings and new IDE_HOME location.
This is currently not happening. As a result, I am installing the new project with the settings of the previous project where I did run the ide create
command.
This can have severe implications and cause effects that even wont repair themselves if I later run ide update
on that newly created project.
OK, I debugged the creation process and I was wrong with my previous comment:
The code (setIdeHome
) properly re-initializes the IdeContext
but the problem is that it does that before cloning the settings. As a result there are no settings and the variables are empty. Hence no JAVA_VERSION
or other such variables are defined and as a result we always get the latest version and not the versions configured in the settings.
The reason that java
gets installed with no variable defined comes from here:
https://github.com/devonfw/IDEasy/blob/b782cc655a9cadab5a2a9e8a4962276536e5c196/cli/src/main/java/com/devonfw/tools/ide/variable/IdeVariables.java#L32
So we install mvn
by default that has a dependency to java
.
As a result, we just need to first clone the settings and initialize the config folder and then re-initialize the IdeContext
.
The only disadvantage I can see with the current solution is that we create and load the EnvironmentVariable
s three times:
ide create
is invokedWe cannot easily omit 1. and we surely want 3. what is the actual fix of this issue. Omitting 2. would save some millis and directory operations but IMHO we should go for KISS and consistency.
Expected behavior
As a IDEasy user, I want to setup a project with create command and get a consistent result so that I can rely on IDEasy.
Actual behavior
I get a wrong Java version installed:
However, if I look at
settings/ide.properties
to see what has been configured, I find this:Steps to reproduce (bug) / Use Case of feature request (enhancement)
ide create demoproject -
Related/Dependent Issues
May be related to #131 However, with Java versions we already had strange effects because of this underscore semantics. See also #235
Comments/Hints:
If I later go the the project and call
ide update
, then it installs21.0.4_7
:This does not make sense.
Affected version: