use of org.kie.internal.builder.IncrementalResults in project kie-wb-common by kiegroup.
the class Builder method buildIncrementally.
private void buildIncrementally(final IncrementalBuildResults results, final String... destinationPath) {
try {
final IncrementalResults incrementalResults = ((InternalKieBuilder) kieBuilder).createFileSet(Message.Level.WARNING, destinationPath).build();
results.addAllAddedMessages(convertMessages(incrementalResults.getAddedMessages(), handles));
results.addAllRemovedMessages(convertMessages(incrementalResults.getRemovedMessages(), handles));
// Tidy-up removed message handles
for (Message message : incrementalResults.getRemovedMessages()) {
handles.remove(Handles.RESOURCE_PATH + "/" + getBaseFileName(message.getPath()));
}
} catch (LinkageError e) {
final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, e.getLocalizedMessage());
logger.warn(msg);
results.addAddedMessage(makeWarningMessage(msg));
} catch (Throwable e) {
final String msg = e.getLocalizedMessage();
logger.error(msg, e);
results.addAddedMessage(makeErrorMessage(msg));
}
}
use of org.kie.internal.builder.IncrementalResults in project drools by kiegroup.
the class KieBuilderSetImpl method build.
@Override
public IncrementalResults build() {
Collection<String> srcFiles = files != null ? asList(files) : kieBuilder.getModifiedResourcesSinceLastMark();
Collection<String> filesToBuild = new ArrayList<>();
if (srcFiles.isEmpty()) {
return new IncrementalResultsImpl();
}
kieBuilder.cloneKieModuleForIncrementalCompilation();
for (String file : srcFiles) {
if (!file.endsWith(".properties")) {
String trgFile = kieBuilder.copySourceToTarget(KiePath.of(file));
if (trgFile != null) {
filesToBuild.add(trgFile);
}
}
}
IncrementalResults result = buildChanges(filesToBuild);
files = null;
kieBuilder.markSource();
return result;
}
use of org.kie.internal.builder.IncrementalResults in project drools by kiegroup.
the class KieBuilderSetImplTest method testBuild.
@Test
public void testBuild() throws Exception {
final KieServices ks = KieServices.Factory.get();
final KieFileSystem kfs = ks.newKieFileSystem();
kfs.write("src/main/resources/rule%201.drl", ruleContent());
final KieBuilderSetImpl kieBuilderSet = new KieBuilderSetImpl(kieBuilder(ks, kfs));
kieBuilderSet.setFiles(new String[] { "src/main/resources/rule%201.drl" });
final IncrementalResults build = kieBuilderSet.build();
assertEquals(0, build.getAddedMessages().size());
assertEquals(0, build.getRemovedMessages().size());
}
use of org.kie.internal.builder.IncrementalResults in project drools by kiegroup.
the class KieBuilderSetImplTest method testBuildPercentageAndWhiteSpaceInName.
@Test
@Ignore("RHPAM-1184, RHDM-601")
public void testBuildPercentageAndWhiteSpaceInName() throws Exception {
final KieServices ks = KieServices.Factory.get();
final KieFileSystem kfs = ks.newKieFileSystem();
kfs.write("src/main/resources/my rule 100% okay.rdrl", ResourceFactory.newInputStreamResource(this.getClass().getResourceAsStream("my rule 100% okay.rdrl")));
final KieBuilderSetImpl kieBuilderSet = new KieBuilderSetImpl(kieBuilder(ks, kfs));
kieBuilderSet.setFiles(new String[] { "src/main/resources/my rule 100% okay.rdrl" });
final IncrementalResults build = kieBuilderSet.build();
assertEquals(0, build.getAddedMessages().size());
assertEquals(0, build.getRemovedMessages().size());
}
use of org.kie.internal.builder.IncrementalResults in project drools by kiegroup.
the class IncrementalCompilationTest method testIncrementalCompilationFromEmptyProject2.
@Test
public void testIncrementalCompilationFromEmptyProject2() {
// DROOLS-5584
final String drl1 = "package org.drools.test;\n" + "global java.util.List list;\n" + "rule \"test1\" when then end\n";
final KieServices ks = KieServices.Factory.get();
ReleaseId id = ks.newReleaseId("org.test", "foo", "1.0-SNAPSHOT");
KieFileSystem kfs = ks.newKieFileSystem();
kfs.generateAndWritePomXML(id);
final KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll(DrlProject.class);
assertEquals(0, kieBuilder.getResults().getMessages(org.kie.api.builder.Message.Level.ERROR).size());
kfs.write("src/main/resources/r1.drl", drl1);
final IncrementalResults addResults1 = ((InternalKieBuilder) kieBuilder).createFileSet("src/main/resources/r1.drl").build();
assertEquals(0, addResults1.getAddedMessages().size());
KieContainer kieContainer = ks.newKieContainer(id);
KieSession kieSession = kieContainer.newKieSession();
assertEquals(1, kieSession.getKieBase().getKiePackages().size());
assertNotNull(kieSession.getKieBase().getKiePackage("org.drools.test"));
kieSession.setGlobal("list", new ArrayList());
Collection<String> globals = kieSession.getGlobals().getGlobalKeys();
assertEquals(1, globals.size());
assertEquals("list", globals.iterator().next());
}
Aggregations