private byte[] createKJar(KieServices ks,
ReleaseId releaseId,
String pom,
String... drls) throws RulesCompilationException {
KieFileSystem kfs = ks.newKieFileSystem();
if (pom != null) {
kfs.write("pom.xml", pom);
} else {
kfs.generateAndWritePomXML(releaseId);
}
for (int i = 0; i < drls.length; i++) {
if (drls[i] != null) {
kfs.write("src/main/resources/r" + i + ".drl", drls[i]);
}
}
for (URL builtinRuleUrl : builtinRuleUrls) {
final Path rulesPath = new File(builtinRuleUrl.getPath()).toPath();
final String path = "src/main/resources/" + rulesPath.getFileName();
final Resource resource = ResourceFactory
.newUrlResource(builtinRuleUrl)
.setSourcePath(path)
.setResourceType(ResourceType.DRL);
kfs.write(resource);
}
KieBuilder kb = ks.newKieBuilder(kfs).buildAll();
if (kb.getResults().hasMessages(org.kie.api.builder.Message.Level.ERROR)) {
throw new RulesCompilationException(kb.getResults().getMessages());