javamavendroolsdrools-guvnorkie

Drools Kie application without Maven


As a developer I want to create a Maven project and build an executable standalone JAR application. (No Spring Boot)

During development and build processes I want to add a Drools Kie artifact as dependency

<dependency>
 <groupId>com.mycompany</groupId>
 <artifactId>mydrools</artifactId>
 <version>[1.0.0,)</version>
</dependency>

build my application as executable Jar and run it. My application has the code to call the Drools engine:

KieSession kSession = kContainer.newKieSession();
kSession.insert(myBean);
kSession.fireAllRules();

Above all, whilst I deploy my application on production:

I have tried with

String fileName = System.getenv("HOME") + "/libs/mydrools-1.0.0.jar";
File file = new File(fileName);
KieRepository kieRepository = ks.getRepository();        
KieContainer kContainer = ks.newKieContainer(ks.newReleaseId("com.mycompany", "mydrools", "1.0.0"));
kieRepository.addKieModule(ks.getResources().newFileSystemResource(file));
KieScanner kScanner = ks.newKieScanner( kContainer );
kScanner.start( 10000L );

Loading the JAR works fine, but it seems that I am also forced to configure at least a minimal Maven repository (~/.m2 folder and a settings.xml). I get a heap of errors by the org.apache.maven plugin and related classes.

Of course I do not want my production environment to rely nor depend on any Maven configuration. I just want to run a JAR with another JAR (e.g. libs/mydrools-1.0.0.jar) as dependency and possibly dynamically reload that dependency whilst I update the libs/mydrools-1.0.0.jar.

Basically I need to set the internal Drools Kie Maven plugin completely disabled (offline).

How is it possible to do this with Drools 6.2.0.Final?

Update

This issue is strictly related with

Using Drools 6 Maven architecture completely offline

http://lists.jboss.org/pipermail/rules-users/2014-June/036245.html


Solution

  • The answer is you don't. KIE 6.* (and 7) has maven built into it, the KieScanner class uses maven to find updates. The scanner will work better if in the ReleaseId you specify a version range e.g. [1.0.0,)

    My company is in the process of deploying KIE based applications to production. We're setting up an Artifactory repository in PROD and there will be a maven repository as well.

    You can essentially disable the maven part by not using KieScanner, instead use the getKieClasspathContainer() to get the KIE container. You won't be doing dynamic updates to rules though.

    KIE also provides an Execution Server which pushes the Rules into a REST API. The Execution Server rules can also be updated via maven.