Space characters between "(" and the type of local variable declaration in the enhanced "for" (foreach) statement causes a compilation error.
Issue
Building a maven project containing rules using the enhanced for (foreach) statement in MVEL dialect with executable rule model disabled sometimes fails.
For example, my project contains a rule written in MVEL dialect like below and uses the enhanced for statement at (*1).
dialect "mvel"
rule "bus1"
when
$buses : ArrayList() from collect ( Bus() )
then
for ( Bus bus : $buses ) { .......... (*1)
System.out.println("bus: " + bus);
}
end
When I build the project with executable rule model disabled, a compilation error occurs with the following error message.
$ mvn clean compile exec:exec -DgenerateModel=NO
...
[ERROR] Unable to build KieBaseModel:rules
Unable to Analyse Expression for ( Bus bus : $buses ) { System.out.println("bus: " + bus); };:
[Error: cannot resolve identifier: Bu]
[Near : {... for ( Bus bus : $buses ) { ....}]
^
[Line: 8, Column: 0] : [Rule name='bus1']
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.504 s
[INFO] Finished at: 2020-11-18T13:00:35+09:00
[INFO] ------------------------------------------------------------------------
...
Environment
- Red Hat Decision Manager (RHDM)
- 7.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.