use of org.drools.compiler.kie.builder.impl.InternalKieModule in project jbpm by kiegroup.
the class BusinessRuleTaskTest method createAndDeployJar.
private byte[] createAndDeployJar(KieServices ks, ReleaseId releaseId, Resource... resources) throws Exception {
KieFileSystem kfs = ks.newKieFileSystem().generateAndWritePomXML(releaseId);
for (int i = 0; i < resources.length; i++) {
if (resources[i] != null) {
kfs.write(resources[i]);
}
}
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
((InternalKieBuilder) kieBuilder).buildAll(o -> true);
Results results = kieBuilder.getResults();
if (results.hasMessages(Message.Level.ERROR)) {
throw new IllegalStateException(results.getMessages(Message.Level.ERROR).toString());
}
InternalKieModule kieModule = (InternalKieModule) ks.getRepository().getKieModule(releaseId);
byte[] pomXmlContent = IOUtils.toByteArray(kieModule.getPomAsStream());
File pom = new File("target", UUID.randomUUID().toString());
Files.write(pom.toPath(), pomXmlContent);
KieMavenRepository.getKieMavenRepository().installArtifact(releaseId, kieModule, pom);
byte[] jar = kieModule.getBytes();
return jar;
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project jbpm by kiegroup.
the class RuntimeDataServiceEJBIntegrationTest method deployKjar.
protected static void deployKjar() {
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
List<String> processes = new ArrayList<String>();
processes.add("processes/EmptyHumanTask.bpmn");
processes.add("processes/humanTask.bpmn");
processes.add("processes/SimpleHTProcess.bpmn2");
InternalKieModule kJar1 = createKieJar(ks, releaseId, processes);
File pom = new File("target/kmodule", "pom.xml");
pom.getParentFile().mkdir();
try {
FileOutputStream fs = new FileOutputStream(pom);
fs.write(getPom(releaseId).getBytes());
fs.close();
} catch (Exception e) {
}
KieMavenRepository repository = getKieMavenRepository();
repository.installArtifact(releaseId, kJar1, pom);
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project jbpm by kiegroup.
the class UserTaskServiceEJBIntegrationTest method deployKjar.
protected static void deployKjar() {
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
List<String> processes = new ArrayList<String>();
processes.add("processes/EmptyHumanTask.bpmn");
processes.add("processes/humanTask.bpmn");
InternalKieModule kJar1 = createKieJar(ks, releaseId, processes);
File pom = new File("target/kmodule", "pom.xml");
pom.getParentFile().mkdir();
try {
FileOutputStream fs = new FileOutputStream(pom);
fs.write(getPom(releaseId).getBytes());
fs.close();
} catch (Exception e) {
}
KieMavenRepository repository = getKieMavenRepository();
repository.installArtifact(releaseId, kJar1, pom);
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project jbpm by kiegroup.
the class AbstractTestSupport method createKieJar.
protected static InternalKieModule createKieJar(KieServices ks, ReleaseId releaseId, List<String> resources, Map<String, String> extraResources) {
KieFileSystem kfs = createKieFileSystemWithKProject(ks);
kfs.writePomXML(getPom(releaseId));
for (String resource : resources) {
kfs.write("src/main/resources/KBase-test/" + resource, ResourceFactory.newClassPathResource(resource));
}
if (extraResources != null) {
for (Map.Entry<String, String> entry : extraResources.entrySet()) {
kfs.write(entry.getKey(), ResourceFactory.newByteArrayResource(entry.getValue().getBytes()));
}
}
kfs.write("src/main/resources/forms/DefaultProcess.ftl", ResourceFactory.newClassPathResource("repo/globals/forms/DefaultProcess.ftl"));
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
if (!kieBuilder.buildAll().getResults().getMessages().isEmpty()) {
for (Message message : kieBuilder.buildAll().getResults().getMessages()) {
logger.error("Error Message: ({}) {}", message.getPath(), message.getText());
}
throw new RuntimeException("There are errors builing the package, please check your knowledge assets!");
}
return (InternalKieModule) kieBuilder.getKieModule();
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project jbpm by kiegroup.
the class DeploymentServiceEJBIntegrationTest method deployKjar.
protected static void deployKjar() {
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
List<String> processes = new ArrayList<String>();
processes.add("processes/customtask.bpmn");
processes.add("processes/humanTask.bpmn");
processes.add("processes/signal.bpmn");
processes.add("processes/import.bpmn");
processes.add("processes/callactivity.bpmn");
InternalKieModule kJar1 = createKieJar(ks, releaseId, processes);
File pom = new File("target/kmodule", "pom.xml");
pom.getParentFile().mkdir();
try {
FileOutputStream fs = new FileOutputStream(pom);
fs.write(getPom(releaseId).getBytes());
fs.close();
} catch (Exception e) {
}
KieMavenRepository repository = getKieMavenRepository();
repository.installArtifact(releaseId, kJar1, pom);
ReleaseId releaseIdSupport = ks.newReleaseId(GROUP_ID, "support", VERSION);
List<String> processesSupport = new ArrayList<String>();
processesSupport.add("processes/support.bpmn");
InternalKieModule kJar2 = createKieJar(ks, releaseIdSupport, processesSupport);
File pom2 = new File("target/kmodule2", "pom.xml");
pom2.getParentFile().mkdir();
try {
FileOutputStream fs = new FileOutputStream(pom2);
fs.write(getPom(releaseIdSupport).getBytes());
fs.close();
} catch (Exception e) {
}
repository.installArtifact(releaseIdSupport, kJar2, pom2);
ReleaseId releaseId3 = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, "1.1.0-SNAPSHOT");
InternalKieModule kJar3 = createKieJar(ks, releaseId3, processes);
File pom3 = new File("target/kmodule3", "pom.xml");
pom3.getParentFile().mkdirs();
try {
FileOutputStream fs = new FileOutputStream(pom3);
fs.write(getPom(releaseId3).getBytes());
fs.close();
} catch (Exception e) {
}
repository = getKieMavenRepository();
repository.installArtifact(releaseId3, kJar3, pom3);
}
Aggregations