Search code examples
eclipseeclipse-plugindrools

How to use drools in an already existing project?


I have an eclipse plug-in project and now I want to use drools into it. The examples I have seen in internet is all about creating a drools project from scratch. I don't want to change the folder structure of my existing project. Can you please help me how can I do this ? Drools enforces some folder structure and file location for the rules to get fired, how to achieve this in my existing project ?


Solution

  • I am not sure about the eclipse plug-in project structure, but with the help of below code you can load rule files from external location or from classpath

    KieServices kieServices = KieServices.Factory.get(); KieFileSystem kfs = kieServices.newKieFileSystem();

    file = "path/to/DRL/file"; resource = kieServices.getResources().newFileSystemResource(file).setResourceType(ResourceType.DRL); kfs.write(resource);

    KieBuilder Kiebuilder = kieServices.newKieBuilder(kfs); Kiebuilder.buildAll();