kie-maven-plugin failure when using Lombok annotation

23 views
Skip to first unread message

Steven Chou

unread,
Sep 12, 2025, 3:49:51 PMSep 12
to Drools Usage
Hi, 
I have run into an issue when using the kie-maven-plugin to produce the kjar when using Lombok annotation.
This can be reproduced with the sample maven project generated from the

mvn archetype:generate -DarchetypeGroupId=org.kie -DarchetypeArtifactId=kie-drools-exec-model-ruleunit-archetype -DarchetypeVersion=8.44.0.Final

Modify the Measurement class by adding the @Data, @AllArgsConstructor and @Builder Lombok annotation like below

@Data
@AllArgsConstructor
@Builder
public class Measurement {
    private String id;
    private String val;
}

Then add the following method to the MeasurementUnit class
   
public void addMeasurement(String id, String value) {
        this.measurements.add(Measurement.builder().id(id).val(value).build());
    }

Now do mvn clean package and I get the build failure message: 

[ERROR] Failed to execute goal org.kie:kie-maven-plugin:10.1.0:build (default-build) on project drools-test: Execution default-build of goal org.kie:kie-maven-plugin:10.1.0:build failed: Unable to create KieModule, Errors Existed: [Message [id=1, level=ERROR, path=src/main/java/com/abc/MeasurementUnit.java, line=26, column=709
[ERROR]    text=The method builder() is undefined for the type Measurement]]
[ERROR] -> [Help 1]

I have tried out  Drools v10.1, 10 and 8.4 with Java 8 or 21 and the error is always the same.
I'm using the latest Lombok version, 1.18.40, with their annotationProcessorPaths setting.

I think the issue is kie-maven-plugin doesn't use the code after it is processed and generated by the Lombok annotation processor, so it can't recognize the build() method generated by the Lombok. Is there any workaround of it?

Thanks,

Steven

Alex Porcelli

unread,
Sep 12, 2025, 3:55:14 PMSep 12
to drools...@googlegroups.com
Hi Steven,

I’m quite sure this is not well captured in docs - so we should review

But I don’t think Drools works with Lombok. Actually several Drools maintainers and community members are quite vocal about NOT USE Lombok

-
Alex
--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/drools-usage/d6b20ea8-ace9-4884-8ec1-66f8f8858443n%40googlegroups.com.

otaf otaf

unread,
Sep 13, 2025, 5:37:00 AMSep 13
to Drools Usage
Hello Steven,

1. There is a big warning with regards to kie-maven plugin on jdk 21 : we have not really made it work (in 10.0.0), because it depends on jdk17 features removed in 21. But this is later in the process of building and as your java code does not compile asis, you have not yet encountered it. I am unsure of the status of this as drools inc the plugin is built in jdk17 

  
2 the correct way or the workaround that we use with Lombok for drools is also that we have separate packages built elsewhere with our model as dependencies in the pom (sol A), but maybe you could manage that with a a parent pom, specifying your dependency from one package to another (sol B). 

Eg  sol A if your Measurement is packaged in a separate maven artifact com.example.myrporject:datamodel:1.0.0-SNAPSHOT, you build that with maven separately (mvn install in the project; or mvn deploy)
then add that as a dependency in your pom for the rules package built with kie-maven    com.example.myrporject:myRulesProject:1.0.1-SNAPSHOT.
 This way, you have a jar of your model, which is used by the "rules" package. 

Sol B is a parent pom listing the 2 projects, and in the filesystem  you have the model in one subproject, and the rules in another, with a dependency to the model. 
Dark maven magic is needed for parent poms and revisions (you can use the $revision variable, put then you will doubtlessly need the flatten maven command in order to publish correct packages) 

Rgds,
otf
Reply all
Reply to author
Forward
0 new messages