allow expressions in template variable definitions #989
Labels
configuration
should be configurable or configuration change
enhancement
New feature or request
merger
settings
ide-settings repo and replated processes and features
Currently we support variable expressions like
$[IDE_HOME]
in templates.In such case if the variable is defined, the expression is literally replaced with its value.
This is fine for most of our use-cases.
However, in some cases we might end up with resolving
$[IDE_HOME]/software/mvn
toD:\projects\my-project/software/mvn
on Windows.Often tools are tolerant and will accept this mixed up path syntax.
However, in some cases backslashes may need extra escaping and the result may not work.
Also we have cases like this:
https://github.com/devonfw/ide-settings/blob/3c41b5e27ad4baa90d4e3ffdf2ac16ca5e95d11a/intellij/workspace/update/.intellij/config/options/nodejs.xml#L4-L5
We could still workaround this somehow by adding a variable
EXECUTABLE_SUFFIX
set to.exe
insettings/ide.properties
and then a MacOS or linux user could override the property as empty (EXECUTABLE_SUFFIX=
) in hisconfig/ide.properties
to make that portable.Expression Syntax
The syntax still needs to be refined but here are some first ideas:
I know the syntax looks strange but this is a first draft:
$[...]
syntax so our regex replace approach can stay$[...]
but use${...}
inside as otherwise it will become more tricky to find the end of the regex expression.$[...]
starts with an at sign@
, then we assume we do not have a plain variable name but an expression/function@
sign and ending before the opening parenthesis(
that must always be present - herepath
in the function name)
.'
and double quotes"
are supported.${IDE_HOME}
$[...]
) will be replaced with.path
function would be called with two String argumentsunix
and e.g./home/mylogin/projects/example/software/node/node?(.exe|.sh|)
./home/mylogin/projects/example/software/node/node
and then iterate the suffixes".exe"
,".sh"
, and""
and during the iteration check if thatjava.nio.Path
exists. If it exists it will be converted to a String usingunix
syntax (so if we are on Windows and have backslashes as separators they will be replaced with normal slashes) and that String is returned. If no Path exists, a warning is logged but the last iterated suffix will be used (here the empty String).'/'
as first argument and consider it as folder separator and could pass\\
as alternative or the empty String''
to keep the OS default - whatever.$[@currentDateTime()]
The text was updated successfully, but these errors were encountered: