use of org.kie.api.builder.ReleaseId in project drools by kiegroup.
the class DrlxCompiler method compileSingleSource.
public static CompiledUnit compileSingleSource(Reader source) {
CompilationUnit compilationUnit = JavaParser.parse(source);
ClassOrInterfaceDeclaration unitClass = (ClassOrInterfaceDeclaration) compilationUnit.getType(0);
String pkg = compilationUnit.getPackageDeclaration().map(PackageDeclaration::getNameAsString).orElse("defaultpkg");
String unit = unitClass.getNameAsString();
KieServices ks = KieServices.get();
ReleaseId releaseId = ks.newReleaseId(pkg, unit, "1.0");
KieFileSystem kfs = createKieFileSystem(ks, releaseId);
String unitPath = pkg.replace(".", "/") + "/" + unit;
String javaPath = "src/main/java/" + unitPath + ".java";
String drlPath = "src/main/resources/" + unitPath + ".drl";
kfs.write(drlPath, toDrl(compilationUnit)).write(javaPath, toJava(compilationUnit));
KieContainer kieContainer = createKieContainer(ks, kfs, releaseId);
return new CompiledUnit(kieContainer, pkg + "." + unit);
}
use of org.kie.api.builder.ReleaseId in project drools by kiegroup.
the class BaseModelTest method getKieContainer.
protected KieContainer getKieContainer(KieModuleModel model, KieFile... stringRules) {
KieServices ks = KieServices.get();
ReleaseId releaseId = ks.newReleaseId("org.kie", "kjar-test-" + UUID.randomUUID(), "1.0");
KieBuilder kieBuilder = createKieBuilder(ks, model, releaseId, stringRules);
return ks.newKieContainer(releaseId);
}
use of org.kie.api.builder.ReleaseId in project drools by kiegroup.
the class KieRepositoryTest method testRemoveKieModuleSnapshot.
/**
* Tests removing a KieModule with a SNAPSHOT ReleaseId from KieRepository.
*/
@Test
public void testRemoveKieModuleSnapshot() {
final ReleaseId releaseId = kieServices.newReleaseId(TestConstants.PACKAGE_TESTCOVERAGE, TEST_ARTIFACT_ID, TEST_ARTIFACT_VERSION_SNAPSHOT);
this.testKieModuleRemoval(releaseId);
}
use of org.kie.api.builder.ReleaseId in project drools by kiegroup.
the class KieRepositoryTest method testAddKieModuleSnapshot.
/**
* Tests adding a KieModule with a SNAPSHOT ReleaseId to KieRepository.
*/
@Test
public void testAddKieModuleSnapshot() {
final ReleaseId releaseId = kieServices.newReleaseId(TestConstants.PACKAGE_TESTCOVERAGE, TEST_ARTIFACT_ID, TEST_ARTIFACT_VERSION_SNAPSHOT);
this.testKieModuleAddition(releaseId);
}
use of org.kie.api.builder.ReleaseId in project drools by kiegroup.
the class BuildtimeUtil method generateKJarFromKieBuilder.
public static void generateKJarFromKieBuilder(final KieBuilder kieBuilder, final boolean useCanonicalModel) throws IOException {
final ReleaseId releaseId = kieBuilder.getKieModule().getReleaseId();
final InternalKieModule kieModule = (InternalKieModule) kieBuilder.getKieModule();
final File kjarFile = bytesToTempFile(releaseId, kieModule.getBytes(), ".jar");
final KieModule zipKieModule;
if (useCanonicalModel) {
zipKieModule = new CanonicalKieModule(releaseId, kieModule.getKieModuleModel(), kjarFile);
} else {
zipKieModule = new ZipKieModule(releaseId, kieModule.getKieModuleModel(), kjarFile);
}
KieServices.get().getRepository().addKieModule(zipKieModule);
}
Aggregations