How do you precompile the Drools rules?

I want to precompile my .drl files into .class files so that they do not have to compile runtime. The documentation makes it sound like the kie-maven-plugin does, but for me it doesn't generate anything. It compiles the rule files, but does not output anything. Any suggestions?

I use the mvn package command and my pom.xml is below:

 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.kie</groupId> <artifactId>kie-parent-with-dependencies</artifactId> <version>6.0.1.Final</version> <!-- relativePath causes out-of-date problems on hudson slaves --> <!--<relativePath>../droolsjbpm-build-bootstrap/pom.xml</relativePath>--> </parent> <packaging>kjar</packaging> <artifactId>default-kiesession</artifactId> <name>Drools API examples - Default KieSession</name> <dependencies> <dependency> <groupId>org.drools</groupId> <artifactId>drools-compiler</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.kie</groupId> <artifactId>kie-maven-plugin</artifactId> <version>6.0.1.Final</version> <extensions>true</extensions> <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.6.1</version> </dependency> </dependencies> </plugin> </plugins> </build> <repositories> <!-- Bootstrap repository to locate the parent pom when the parent pom has not been build locally. --> <repository> <id>jboss-public-repository-group</id> <name>JBoss Public Repository Group</name> <url>http://repository.jboss.org/nexus/content/groups/public/</url> <layout>default</layout> <releases> <enabled>true</enabled> <updatePolicy>never</updatePolicy> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>daily</updatePolicy> </snapshots> </repository> </repositories> <scm> <connection>scm:git: git@github.com :droolsjbpm/drools.git</connection> <developerConnection>scm:git: git@github.com :droolsjbpm/drools.git</developerConnection> <url>https://github.com/droolsjbpm/drools</url> </scm> </project> 
+6
source share
2 answers

There was an error in version 6.0.1. This caused the maven plugin, which did not save the compiled bytecode inside kjar. It was fixed after, so if you use version 6.0.2-SNAPSHOT (community) or version RedHat BRMS 6.0.1.GA (product), it will work.

BZ ticket: https://bugzilla.redhat.com/show_bug.cgi?id=1063255

commit that fixes the error: https://github.com/droolsjbpm/drools/commit/94b9ccf810100c7ec3f8ed186111720ddb2729d3

FYI, when the correct kjar is generated, it contains the kbase.cache file inside the jar for each specific kbase. These cache files contain compiled bytecode.

+5
source

It works for me with kie-maven-plugin 6.1.0.Final, but you need to specify the "kjar" package to get the KIE cache inside the jar file.

+2
source

All Articles