use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class BuildExecutorTest method mockBuildService.
private void mockBuildService(final BuildService buildService) {
when(buildService.build(any(KieModule.class))).thenReturn(new BuildResults());
when(buildService.buildAndDeploy(any(KieModule.class), any(DeploymentMode.class))).thenReturn(new BuildResults());
}
use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class BuilderConcurrencyIntegrationTest method testBuilderConcurrency.
@Test
public // https://bugzilla.redhat.com/show_bug.cgi?id=1145105
void testBuilderConcurrency() throws URISyntaxException {
final URL pomUrl = this.getClass().getResource("/BuilderConcurrencyRepo/pom.xml");
final org.uberfire.java.nio.file.Path nioPomPath = fs.getPath(pomUrl.toURI());
final Path pomPath = paths.convert(nioPomPath);
final URL resourceUrl = this.getClass().getResource("/BuilderConcurrencyRepo/src/main/resources/update.drl");
final org.uberfire.java.nio.file.Path nioResourcePath = fs.getPath(resourceUrl.toURI());
final Path resourcePath = paths.convert(nioResourcePath);
final SessionInfo sessionInfo = mock(SessionInfo.class);
// Force full build before attempting incremental changes
final KieModule project = moduleService.resolveModule(resourcePath);
final BuildResults buildResults = buildService.build(project);
assertNotNull(buildResults);
assertEquals(0, buildResults.getErrorMessages().size());
assertEquals(1, buildResults.getInformationMessages().size());
// Perform incremental build
final int THREADS = 200;
final Result result = new Result();
ExecutorService es = Executors.newCachedThreadPool();
for (int i = 0; i < THREADS; i++) {
switch(i % 3) {
case 0:
es.execute(new Runnable() {
@Override
public void run() {
try {
logger.debug("Thread " + Thread.currentThread().getName() + " has started: BuildService.build( project )");
buildService.build(project);
logger.debug("Thread " + Thread.currentThread().getName() + " has completed.");
} catch (Throwable e) {
result.setFailed(true);
result.setMessage(e.getMessage());
logger.debug(e.getMessage());
}
}
});
break;
case 1:
es.execute(new Runnable() {
@Override
public void run() {
try {
logger.debug("Thread " + Thread.currentThread().getName() + " has started: LRUModuleDataModelOracleCache.invalidateModuleCache(...)");
moduleDMOCache.invalidateModuleCache(new InvalidateDMOModuleCacheEvent(sessionInfo, project, pomPath));
logger.debug("Thread " + Thread.currentThread().getName() + " has completed.");
} catch (Throwable e) {
result.setFailed(true);
result.setMessage(e.getMessage());
logger.debug(e.getMessage());
}
}
});
break;
default:
es.execute(new Runnable() {
@Override
public void run() {
try {
logger.debug("Thread " + Thread.currentThread().getName() + " has started: LRUBuilderCache.assertBuilder( project ).getKieModuleIgnoringErrors();");
builderCache.assertBuilder(project).getKieModuleIgnoringErrors();
logger.debug("Thread " + Thread.currentThread().getName() + " has completed.");
} catch (Throwable e) {
result.setFailed(true);
result.setMessage(e.getMessage());
logger.debug(e.getMessage());
}
}
});
}
}
es.shutdown();
try {
es.awaitTermination(5, TimeUnit.MINUTES);
} catch (InterruptedException e) {
}
if (result.isFailed()) {
fail(result.getMessage());
}
}
use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class BuildHelper method build.
public BuildResult build(final Module module) {
try {
cache.invalidateCache(module);
Builder builder = cache.assertBuilder(module);
final BuildResults results = builder.build();
BuildMessage infoMsg = new BuildMessage();
infoMsg.setLevel(Level.INFO);
infoMsg.setText(buildResultMessage(module, results).toString());
results.addBuildMessage(0, infoMsg);
return new BuildResult(builder, results);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new BuildResult(null, buildExceptionResults(e, module.getPom().getGav()));
}
}
use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class Builder method getKieContainer.
public KieContainer getKieContainer() {
BuildResults results = null;
// Kie classes are only available once built
if (!isBuilt()) {
results = build();
} else {
results = new BuildResults();
results.addAllBuildMessages(convertMessages(kieBuilder.getResults().getMessages(), handles));
}
// It's impossible to retrieve a KieContainer if the KieModule contains errors
if (results.getErrorMessages().isEmpty()) {
// Do not retrieve the KieContainer with KieServices.newKieContainer(releaseId) since this looks-up the KieModule to
// create the KieContainer from KieRepository. This holds the most recent KieModule (for the ReleaseId) that was built with
// kieBuilder.buildAll() which *may* be a KieModule created during asset validation and hence will lack many assets.
// See https://bugzilla.redhat.com/show_bug.cgi?id=1202551
final org.kie.api.builder.KieModule kieModule = kieBuilder.getKieModule();
final ReleaseId releaseId = kieModule.getReleaseId();
final org.drools.compiler.kie.builder.impl.KieProject kieProject = new KieModuleKieProject((InternalKieModule) kieBuilder.getKieModule(), null);
final KieContainer kieContainer = new KieContainerImpl(kieProject, KieServices.Factory.get().getRepository(), releaseId);
return kieContainer;
} else {
return null;
}
}
use of org.guvnor.common.services.project.builder.model.BuildResults in project kie-wb-common by kiegroup.
the class BuilderTest method testBuilderKModuleHasSnapshotDependency.
@Test
public void testBuilderKModuleHasSnapshotDependency() throws Exception {
URL url = this.getClass().getResource("/GuvnorM2RepoDependencyExample2Snapshot");
SimpleFileSystemProvider p = new SimpleFileSystemProvider();
org.uberfire.java.nio.file.Path path = p.getPath(url.toURI());
final Module module = moduleService.resolveModule(Paths.convert(path));
final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue);
final BuildResults results = builder.build();
// Debug output
if (!results.getMessages().isEmpty()) {
for (BuildMessage m : results.getMessages()) {
logger.debug(m.getText());
}
}
assertTrue(results.getMessages().isEmpty());
}
Aggregations