Search in sources :

Example 1 with ResultsImpl

use of org.drools.compiler.kie.builder.impl.ResultsImpl in project drools by kiegroup.

the class KieRepositoryScannerImpl method updateKieModule.

private boolean updateKieModule(DependencyDescriptor oldDependency, Artifact artifact) {
    org.appformer.maven.support.AFReleaseId newReleaseId = new DependencyDescriptor(artifact).getReleaseId();
    InternalKieModule kieModule = createKieModule(newReleaseId, artifact.getFile());
    if (kieModule != null) {
        addDependencies(kieModule, artifactResolver, artifactResolver.getArtifactDependecies(newReleaseId.toString()));
        ResultsImpl messages = kieModule.build();
        if (messages.filterMessages(Message.Level.ERROR).isEmpty()) {
            Results updateMessages = kieContainer.updateDependencyToVersion(adapt(oldDependency.getArtifactReleaseId()), adapt(newReleaseId));
            oldDependency.setArtifactVersion(artifact.getVersion());
            // append all update Results into build Results to notify listeners
            messages.getMessages().addAll(updateMessages.getMessages());
        }
        listeners.fireKieScannerUpdateResultsEventImpl(messages);
        return !messages.hasMessages(Message.Level.ERROR);
    }
    return false;
}
Also used : DependencyDescriptor(org.appformer.maven.integration.DependencyDescriptor) Results(org.kie.api.builder.Results) ResultsImpl(org.drools.compiler.kie.builder.impl.ResultsImpl) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule)

Example 2 with ResultsImpl

use of org.drools.compiler.kie.builder.impl.ResultsImpl in project drools by kiegroup.

the class KieHelloWorldTest method testClassLoaderStore.

@Test
public void testClassLoaderStore() throws Exception {
    // DROOLS-1766
    String drl = "package org; declare Person name : String end";
    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/r1.drl", drl);
    ks.newKieBuilder(kfs).buildAll();
    KieContainer kcontainer = ks.newKieContainer(ks.getRepository().getDefaultReleaseId());
    KieProject kieProject = ((KieContainerImpl) kcontainer).getKieProject();
    ResultsImpl messages = kieProject.verify();
    assertSame(kieProject.getClassLoader(), kcontainer.getClassLoader());
    ProjectClassLoader pcl = ((ProjectClassLoader) kieProject.getClassLoader());
    assertNotNull(pcl.getStore().get("org/Person.class"));
}
Also used : ProjectClassLoader(org.drools.core.common.ProjectClassLoader) KieFileSystem(org.kie.api.builder.KieFileSystem) KieProject(org.drools.compiler.kie.builder.impl.KieProject) KieContainerImpl(org.drools.compiler.kie.builder.impl.KieContainerImpl) KieServices(org.kie.api.KieServices) ResultsImpl(org.drools.compiler.kie.builder.impl.ResultsImpl) KieContainer(org.kie.api.runtime.KieContainer) Test(org.junit.Test)

Aggregations

ResultsImpl (org.drools.compiler.kie.builder.impl.ResultsImpl)2 DependencyDescriptor (org.appformer.maven.integration.DependencyDescriptor)1 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)1 KieContainerImpl (org.drools.compiler.kie.builder.impl.KieContainerImpl)1 KieProject (org.drools.compiler.kie.builder.impl.KieProject)1 ProjectClassLoader (org.drools.core.common.ProjectClassLoader)1 Test (org.junit.Test)1 KieServices (org.kie.api.KieServices)1 KieFileSystem (org.kie.api.builder.KieFileSystem)1 Results (org.kie.api.builder.Results)1 KieContainer (org.kie.api.runtime.KieContainer)1