use of org.drools.compiler.kie.builder.impl.InternalKieModule in project drools by kiegroup.
the class AbstractKieCiTest method createKieJarWithClass.
protected InternalKieModule createKieJarWithClass(KieServices ks, ReleaseId releaseId, boolean useTypeDeclaration, int value, int factor, ReleaseId... dependencies) throws IOException {
KieFileSystem kfs = createKieFileSystemWithKProject(ks, false);
kfs.writePomXML(getPom(releaseId, dependencies));
if (useTypeDeclaration) {
kfs.write("src/main/resources/KBase1/rule1.drl", createDRLWithTypeDeclaration(value, factor));
} else {
kfs.write("src/main/resources/KBase1/rule1.drl", createDRLForJavaSource(value)).write("src/main/java/org/kie/test/Bean.java", createJavaSource(factor));
}
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
assertTrue(kieBuilder.buildAll().getResults().getMessages().isEmpty());
return (InternalKieModule) kieBuilder.getKieModule();
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project drools by kiegroup.
the class AbstractKieCiTest method createKJar.
public static byte[] createKJar(KieServices ks, ReleaseId releaseId, String pom, String... drls) {
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]);
}
}
KieBuilder kb = ks.newKieBuilder(kfs).buildAll();
if (kb.getResults().hasMessages(org.kie.api.builder.Message.Level.ERROR)) {
for (org.kie.api.builder.Message result : kb.getResults().getMessages()) {
System.out.println(result.getText());
}
return null;
}
InternalKieModule kieModule = (InternalKieModule) ks.getRepository().getKieModule(releaseId);
byte[] jar = kieModule.getBytes();
return jar;
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project drools by kiegroup.
the class KieRepositoryScannerImpl method buildArtifact.
private InternalKieModule buildArtifact(Artifact artifact, ArtifactResolver resolver) {
DependencyDescriptor dependencyDescriptor = new DependencyDescriptor(artifact);
ReleaseId releaseId = adapt(dependencyDescriptor.getReleaseId());
if (releaseId.isSnapshot()) {
((ReleaseIdImpl) releaseId).setSnapshotVersion(artifact.getVersion());
}
InternalKieModule kieModule = createKieModule(releaseId, artifact.getFile());
if (kieModule != null) {
addDependencies(kieModule, resolver, resolver.getArtifactDependecies(dependencyDescriptor.toString()));
kieModule.build();
}
return kieModule;
}
Aggregations