use of org.kie.workbench.common.services.backend.builder.service.BuildInfo 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();
}
Aggregations