filter and variable inside a macro [message #1839273] |
Thu, 18 March 2021 14:37 |
NoDataFound - Messages: 10 Registered: October 2017 |
Junior Member |
|
|
Hello,
I have some trouble understanding how variable replacement (expansion) works in macro: my macro defines one parameter and several variables.
First, when I executed the setup, Oomph was asking me to fill in the variables. <macroTaskId>.variableName. From the documentation, I found that this was normal, and that ${variableName} was replaced by ${<macroTaskId>.variableName}. However it still failed because each variableTask had an ID property which was the same as the Name.
After removing the ID, the Oomph UI no longer asked me for those variables.
Now I am stuck with the filter I used, because I'd want to have one macro and several installation, and select disable some plugins if the target installation does not requires it.
1) if I try to use the parameter defined on the macro, and by the parent installation, such as (param1=a), then when the macro is expanded with param1=a, task that should be there (a Resource creation task), are absent. As if the param1 never matched.
2) if I try to set a variable containing the parameter, this also fails.
In the macro preview, I found that the filter was still referencing var1 or param1:
The ResourceCreationTask for my tests are defined as below (the setup is more complex, and I don't have the time yet to provide a simplified example ):
<setupTask xsi:type="setup:ResourceCreationTask" filter="(param1=a)" force="true" targetURL="${install.location}/filter-a">
<content>BLA</content></setupTask>
<setupTask xsi:type="setup:ResourceCreationTask" filter="(*param1=a)" force="true" targetURL="${install.location}/filter-b">
<content>BLA</content></setupTask>
<setupTask xsi:type="setup:ResourceCreationTask" filter="(arg1=a)" targetURL="${install.location}/filter-c">
<content>BLA</content></setupTask>
<setupTask xsi:type="setup:ResourceCreationTask" filter="(*arg1=a)" targetURL="${install.location}/filter-d">
<content>BLA</content></setupTask>
In the preview I can see that
1) task 1 and 2 are still using param1 or *param1.
2) (arg1=a) is replaced by (macroTaskId.arg1=a) if name does not start with *
3) (*arg1) is replaced by (*macroTaskId.arg1=a) if name starts with '*'
4) if the expression is more complexed, eg: ( | (arg1=a) (arg1=b)) then, only the right most one is replaced.
How can I use a parameter or a variable in a filter found in a macro ?
|
|
|
|
Re: filter and variable inside a macro [message #1839400 is a reply to message #1839273] |
Fri, 19 March 2021 23:41 |
NoDataFound - Messages: 10 Registered: October 2017 |
Junior Member |
|
|
Yes, an example will be better.
I attached 3 setups :
- The one containing the macro, TestMacro.setup. It only creates files using a different name each time (TASK-00X)
- The INSTALLID001 setup
- The INSTALLID002 setup
And the installer shows me that:
You can see in the second screenshot (INSTALLID002), the filter of TASK-002 is transformed from ( | (installType=INSTALLID001) (installType=INSTALLID002)) to ( | (installType=INSTALLID001) (*nodatafound.macro1.installType=INSTALLID002)).
I would expect the following tasks for INSTALLID001 : TASK-001 to TASK-012,
And for the second INSTALLID002 : TASK-002, TASK-004, TASK-006, TASK-008, TASK-010 and TASK-12
I am perhaps doing my filter wrong, I'm not accustomed to infix notation :)
Beside, I fail to understand the use case of "*" in the variable name/reference or in the filter.
Is that only for parameters ? If yes, shouldn't the installer/editor report an error instead ?
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04336 seconds