Adriank
Adriank

Reputation: 31

Drools 6.4 KieScanner how to specify what what Maven repo to use

I am new to Drools and am trying to use KieScanner to do hot swap of my rules. I have read the documentation and the discussions around this subject. I am not clear on a few things. The following code snippet is straight from Drools 6.4 documentation:

KieServices kieServices = KieServices.Factory.get();
ReleaseId releaseId = kieServices.newReleaseId( "org.acme", "myartifact", "1.0-SNAPSHOT" );
KieContainer kContainer = kieServices.newKieContainer( releaseId );
KieScanner kScanner = kieServices.newKieScanner( kContainer );
  1. How do I tell the code what maven repository to use?
  2. What are the artifacts that goes into the jar file? Rule files, plus pojo changes. Anything else?

Thank you so much for your help in advance.

Upvotes: 0

Views: 4201

Answers (1)

tarilabs
tarilabs

Reputation: 2398

  1. By default it will use the standard Maven settings hierarchy (system, user, ...), unless you specify a custom Maven settings file.

For this, you can reference the documentation chapter 4.2.3.5 "Settings.xml and Remote Repository Setup":

The settings.xml file can be located in 3 locations, the actual settings used is a merge of those 3 locations.

  • The Maven install: $M2_HOME/conf/settings.xml
  • A user's install: ${user.home}/.m2/settings.xml
  • Folder location specified by the system property kie.maven.settings.custom

The settings.xml is used to specify the location of remote repositories.

Personally, I find very helpful to specify to the KieScanner a custom Maven settings file via the system property kie.maven.settings.custom, because normally I have my KJAR artifacts and Jar of the "model" only in a custom internal repository (and not on public repo or Maven central).

  1. The KJAR should be simply a new release of the previous KJAR.

I think meaningful here to highlight what is my personal common pitfall with hot-swap rules... Be aware drools incremental compilation works at resources level, so if a rule should not re-trigger after the hot-swap, either make sure you have guarding condition on the LHS that will naturally ensure that will be guaranteed, or either you should keep those unmodified rules isolated in their own resources(/files).

Hope this helps

Upvotes: 2

Related Questions