KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write( "src/main/resources/r1.drl", drl );
KieModuleModel module = ks.newKieModuleModel();
// define first kbase
final String defaultBaseName = "defaultKBase";
KieBaseModel defaultBase = module.newKieBaseModel(defaultBaseName);
defaultBase.setDefault(true);
defaultBase.addPackage("*");
defaultBase.newKieSessionModel("defaultKSession").setDefault(true);
// define second kbase including resources of the first one
final String includingBaseName = "includingKBase";
KieBaseModel includingBase = module.newKieBaseModel(includingBaseName);
includingBase.setDefault(false);
includingBase.addInclude(defaultBaseName);
includingBase.newKieSessionModel("includingKSession").setDefault(false);
kfs.writeKModuleXML(module.toXML());
KieBuilder kb = ks.newKieBuilder( kfs ).buildAll();
assertEquals( 0, kb.getResults().getMessages().size() );
KieSession ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();
FactType factType = ksession.getKieBase().getFactType("org.drools.compiler.integrationtests", "CancelFact");