use of org.guvnor.common.services.project.builder.model.IncrementalBuildResults in project kie-wb-common by kiegroup.
the class BuildHelper method addPackageResource.
public IncrementalBuildResults addPackageResource(final Path resource) {
try {
IncrementalBuildResults results = new IncrementalBuildResults();
final KieModule module = moduleService.resolveModule(resource);
if (module == null) {
return results;
}
final Builder builder = cache.assertBuilder(module);
if (!builder.isBuilt()) {
throw new IllegalStateException("Incremental Build requires a full build be completed first.");
} else {
results = builder.addResource(Paths.convert(resource));
}
return results;
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw ExceptionUtilities.handleException(e);
}
}
use of org.guvnor.common.services.project.builder.model.IncrementalBuildResults in project kie-wb-common by kiegroup.
the class BuildHelper method updatePackageResource.
public IncrementalBuildResults updatePackageResource(final Path resource) {
try {
final Module module = moduleService.resolveModule(resource);
if (module == null) {
return new IncrementalBuildResults();
}
final Builder builder = cache.assertBuilder(module);
if (!builder.isBuilt()) {
throw new IllegalStateException("Incremental Build requires a full build be completed first.");
}
return builder.updateResource(Paths.convert(resource));
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw ExceptionUtilities.handleException(e);
}
}
use of org.guvnor.common.services.project.builder.model.IncrementalBuildResults in project kie-wb-common by kiegroup.
the class ValidatorBuildService method doValidation.
private List<ValidationMessage> doValidation(final Path resourcePath, final InputStream inputStream) throws NoModuleException {
final ValidatorResultBuilder resultBuilder = new ValidatorResultBuilder();
final Module module = module(resourcePath);
final org.uberfire.java.nio.file.Path nioResourcePath = Paths.convert(resourcePath);
// Incremental Build does not support Java classes
if (isIncrementalBuildPossible(resourcePath)) {
// Build the Builder from the cache so it's "built" state can be preserved for re-use
BuildInfo buildInfo = buildInfoService.getBuildInfo(module);
final Builder clone = ((BuildInfoImpl) buildInfo).getBuilder().clone();
// First delete resource otherwise if the resource already had errors following builder.build()
// the incremental compilation will not report any additional errors and the resource will be
// considered valid.
clone.deleteResource(nioResourcePath);
final IncrementalBuildResults incrementalBuildResults = clone.updateResource(nioResourcePath, inputStream);
resultBuilder.add(incrementalBuildResults.getAddedMessages());
} else {
Builder builder = builderCache.assertBuilder(module(resourcePath));
final Builder clone = builder.clone();
resultBuilder.add(clone.build(nioResourcePath, inputStream).getMessages());
}
return resultBuilder.results();
}
use of org.guvnor.common.services.project.builder.model.IncrementalBuildResults in project kie-wb-common by kiegroup.
the class BuildPipelineTest method doTestIncrementalBuildResourceExecution.
private void doTestIncrementalBuildResourceExecution(KieModule module, String resourceUri, LocalBuildConfig.BuildType buildType) {
// prepare the pipeline input.
Input input = createIncrementalBuildInput(ROOT_PATH_URI, resourceUri, buildType.name());
// execute the pipeline and verify the result.
pipelineInitializer.getExecutor().execute(input, pipe, (Consumer<LocalBinaryConfig>) localBinaryConfig -> {
assertEquals(incrementalBuildResults, localBinaryConfig.getIncrementalBuildResults());
}, pipelineEventListener);
// verify that all stages were properly invoked.
verifyLocalSourceConfigWasInvoked();
verifyLocalProjectConfigWasInvoked();
verifyLocalBuildConfigExecutorWasInvoked(module, resourceUri, buildType.name());
verifyLocalBuildExecConfigExecutorWasInvoked(module, Paths.convert(getNioPath(resourceUri)), buildType);
// verify the pipeline events where properly raised.
verifyPipelineEvents();
}
use of org.guvnor.common.services.project.builder.model.IncrementalBuildResults in project kie-wb-common by kiegroup.
the class ResourceChangeIncrementalBuilderTest method testResourceDeleted.
@Test
public void testResourceDeleted() throws Exception {
final URL resourceUrl = this.getClass().getResource("/BuildChangeListenerRepo/src/main/resources/delete.drl");
final org.uberfire.java.nio.file.Path nioResourcePath = fs.getPath(resourceUrl.toURI());
final Path resourcePath = paths.convert(nioResourcePath);
// Force full build before attempting incremental changes
final KieModule module = moduleService.resolveModule(resourcePath);
final BuildResults buildResults = buildService.build(module);
assertNotNull(buildResults);
assertEquals(0, buildResults.getErrorMessages().size());
assertEquals(1, buildResults.getInformationMessages().size());
// Perform incremental build
buildChangeListener.deleteResource(resourcePath);
waitForIncrementalBuildResults(buildResultsObserver);
final IncrementalBuildResults incrementalBuildResults = buildResultsObserver.getIncrementalBuildResults();
assertNotNull(incrementalBuildResults);
assertEquals(0, incrementalBuildResults.getAddedMessages().size());
assertEquals(0, incrementalBuildResults.getRemovedMessages().size());
}
Aggregations