Variable value and default value [message #1799169] |
Fri, 30 November 2018 16:45  |
Eclipse User |
|
|
|
I am running Oomph in basic mode. I have a variable say mirror with a default value of dm and no value defined. If I start oomph in basic mode it asks me to switch to advanced mode or else it exits because mirror id undefined. If I start oomph with an environment variable mirror=m then it will work in basic mode and use m. If I set the value to dm and create the same environment variable it will not use it.
How can I use the default value when there is no environment variable defined and use the environment variable when it is defined? Or am I misunderstanding something? I even tried defining mirror with a default value of ${mirror.default} whose value is set to dm but that did not work.
|
|
|
|
|
Re: Variable value and default value [message #1799212 is a reply to message #1799206] |
Sun, 02 December 2018 07:52   |
Eclipse User |
|
|
|
You could use the following approach to conditionally define the default value of a variable:<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:setup="http://www.eclipse.org/oomph/setup/1.0">
<setup:EclipseIniTask
option="-Da.b.c="
value="${a.b.c}"
vm="true"/>
<setup:VariableTask
name="a.b.c"
defaultValue="foo"/>
<setup:VariableTask
filter="(a.b.c.default=*)"
name="a.b.c"
defaultValue="${a.b.c.default}"/>
</xmi:XMI>
This variable would still be prompted.
You could use the following very similar approach to define the value of a variable:<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:setup="http://www.eclipse.org/oomph/setup/1.0">
<setup:EclipseIniTask
option="-Da.b.c="
value="${a.b.c}"
vm="true"/>
<setup:VariableTask
name="a.b.c"
value="foo"/>
<setup:VariableTask
filter="(a.b.c.default=*)"
name="a.b.c"
value="${a.b.c.default}"/>
</xmi:XMI>
This variable would not be prompted and could be used in Simple mode.
Explaining how variable evaluation works is rather complicated. In the end, it's driven primarily by the actual use of the variables in the tasks. When used, the variable's value must be resolved, and to resolve, the actual definition of the variable is used, at which point the value of that variable is used, which could of course involve more variables needing to be resolved; if there is no such variable defined, the system properties or the environment variables are considered for the value. Defaults are used to initialize the UI field of any prompted variable (and if there are choices, the first choice acts like a default). But this only kicks in for Advanced mode and in that mode, the user can change the value to trigger re-evaluation. The user could even introduce new variable references in the field which could introduce yet another a variable that needs prompting, if it is not already defined.
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07393 seconds