Example 15: Import static does not work, where may I find JRuleItemNames?
Closed this issue · 13 comments
I tried to make a rule similar to example 15:
package org.openhab.automation.jrule.rules.user;
import static org.openhab.automation.jrule.generated.items.JRuleItemNames.Bureau_IR_group;
import org.openhab.automation.jrule.rules.JRuleLogName;
import org.openhab.automation.jrule.rules.JRuleName;
import org.openhab.automation.jrule.rules.JRuleWhenItemChange;
import org.openhab.automation.jrule.rules.event.JRuleItemEvent;
public class BureauGroupChange extends JRuleBase {
public static final String MYRULECLASS = "BureauGroupChange";
public static final String MYLOGNAME = MYRULECLASS + "_RULE";
@JRuleName(MYRULECLASS)
@JRuleLogName(MYLOGNAME)
@JRuleWhenItemChange(item = Bureau_IR_group/*, memberOf = JRuleMemberOf.Items*/)
public synchronized void groupMySwitchGroupChanged(JRuleItemEvent event) {
final String memberThatChangedStatus = ((JRuleItemEvent) event).getMemberName();
logInfo(MYLOGNAME + " {} changed to {}", memberThatChangedStatus, event.getState());
}
}
The compiler complains:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.297 s
[INFO] Finished at: 2023-02-23T19:47:01+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project openhabrules: Compilation failure: Compilation failure:
[ERROR] /p:/dokumente/uwe/garden-control/openhab/automation/jrule/openhabrules/src/main/java/org/openhab/automation/jrule/rules/user/BureauGroupChange.java:[4,59] Symbol nicht gefu
nden
[ERROR] Symbol: Klasse JRuleItemNames
[ERROR] Ort: Package org.openhab.automation.jrule.generated.items
[ERROR] /p:/dokumente/uwe/garden-control/openhab/automation/jrule/openhabrules/src/main/java/org/openhab/automation/jrule/rules/user/BureauGroupChange.java:[4,1] **Statischer Import
nur aus Klassen und Schnittstellen**
[ERROR] /p:/dokumente/uwe/garden-control/openhab/automation/jrule/openhabrules/src/main/java/org/openhab/automation/jrule/rules/user/BureauGroupChange.java:[18,33] Symbol nicht gef
unden
[ERROR] Symbol: Variable Bureau_IR_group
[ERROR] Ort: Klasse org.openhab.automation.jrule.rules.user.BureauGroupChange
[ERROR] -> [Help 1]
[ERROR]
- A simple Hello World example rule with a switch item is working.
Thus, my pom.xml seems to be o.k. - A similar DSL rule is working
- I am running OH 3.3.0 under openhabian.
- Development is under Windows 11, VS Studio 1.75
- I made sure the local repo under /.m2 contains the same jrule.jar and jrule-generated.jar as the one in /etc/openhab/
have you imported the generated jrule-jar like this:
<dependency>
<groupId>org.openhab</groupId>
<artifactId>openhab-generated</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jrule-generated.jar</systemPath>
</dependency>
Can the dependency (which you put manually in your m2-repo?) be resolved from maven?
Inside the jar must be this package: org.openhab.automation.jrule.generated
I thought so, that it was completely resolved. Well, when you compile the error still persists?
Have you installed the jar to your repo with install:install-file?
Isn't VS-Code showing an error?
If you attach the jar file i can check.
What release are you using. The BETA15 will not work.
I'm about to build a new release but we had quite a lot of refactorings, but I'll do it shortly.
jrule-3.x.x-BETA16-prebuild.zip
You will have to decompress it first.
@uwejanssen19 did you test with the version from @seaside1 ?
There is a new BETA16 release as well, so please try and update and see if you can get it to work.
No response from reporter. Reopen if problem persist.