Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Oomph » filter and variable inside a macro
filter and variable inside a macro [message #1839273] Thu, 18 March 2021 14:37 Go to next message
NoDataFound - is currently offline NoDataFound -Friend
Messages: 8
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 #1839346 is a reply to message #1839273] Fri, 19 March 2021 13:02 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 32111
Registered: July 2009
Senior Member
I'm really not sure the interaction between filters and macro expansion. I'd need to synthesize an example to see how exactly that works...

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: filter and variable inside a macro [message #1839400 is a reply to message #1839273] Fri, 19 March 2021 23:41 Go to previous messageGo to next message
NoDataFound - is currently offline NoDataFound -Friend
Messages: 8
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:

index.php/fa/40179/0/
index.php/fa/40180/0/

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 ?





Re: filter and variable inside a macro [message #1839478 is a reply to message #1839400] Mon, 22 March 2021 10:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 32111
Registered: July 2009
Senior Member
There's definitely a bug that all the varialbes in the filter are not replaced properly (for more complex filter expressions).

I tried changing org.eclipse.oomph.setup.internal.core.SetupTaskPerformer.FILTER_MEMBER_PATTERN to this:

private static final Pattern FILTER_MEMBER_PATTERN = Pattern.compile("(\\(\\s*)([^|&!~<>=\\(\\)]+)([~<>=\\\\(\\\\)][^\\)]+\\))"); //$NON-NLS-1$

That appears to do a better job. Please open a Bugzilla.

You might want to test this yourself and setup up a development environment.

https://www.eclipse.org/setups/installer/?url=http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/configurations/OomphConfiguration.setup&show=true

For testing, you can launch an IDE and in that IDE you can have your MacroTest.setup and open the Workspace.setup to use it there. Then you can do Perform Setup Tasks to see how it works in the wizard.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: filter and variable inside a macro [message #1839500 is a reply to message #1839478] Mon, 22 March 2021 20:24 Go to previous messageGo to next message
NoDataFound - is currently offline NoDataFound -Friend
Messages: 8
Registered: October 2017
Junior Member
I tested and create the bugreport here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=572201

However what's the "*" for in the name?

[Updated on: Mon, 22 March 2021 21:21]

Report message to a moderator

Re: filter and variable inside a macro [message #1839514 is a reply to message #1839500] Tue, 23 March 2021 06:25 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 32111
Registered: July 2009
Senior Member
That's described here:

https://wiki.eclipse.org/Eclipse_Oomph_Authoring#Macro_Expansion_Processing

The idea being that because macro are literally copied during expansion, you can sure that the variable names being used are strictly local to where they are declared/define in the macro itself rather than a reference to some that may or may not be declared in the context.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Eclipse Installer - Installation failed with an error
Next Topic:setup content assist
Goto Forum:
  


Current Time: Tue Dec 07 19:23:01 GMT 2021

Powered by FUDForum. Page generated in 0.02159 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top