I'm trying to run a set of commands for each selected element.
E.g. I select app1, app2 and app3 folders and for each of them I want to run:
cd {selected_folder}
mvn package (wait till finish)
cd target
java with some parameters (this should be run in separate process, I think start command should do what I want)
The most conceptually simple way, since it's all MS-DOS commands by the look it, is to make a separate .bat file with what you want to run for each item, then make an Opus button which calls the .bat file for each item.
If you use {filepath$} or a similar single-file code on a line, Opus will automatically repeat that line for each selected file/folder when you run the button. You can use that to run the .bat file. (Often, you can use that to do everything, but not in this case: You want to ensure all the commands are done for each item before moving to the next item, rather than do each line for every file before moving to the next line.)
You can also do it without involving external files by using User Commands or scripting. Scripting will give you the most control, but is more complex than using a simple .bat file.