Search in sources :

Example 1 with Builder

use of org.kie.workbench.common.services.backend.builder.core.Builder 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();
}
Also used : IncrementalBuildResults(org.guvnor.common.services.project.builder.model.IncrementalBuildResults) BuildInfo(org.kie.workbench.common.services.backend.builder.service.BuildInfo) Builder(org.kie.workbench.common.services.backend.builder.core.Builder) Module(org.guvnor.common.services.project.model.Module)

Aggregations

IncrementalBuildResults (org.guvnor.common.services.project.builder.model.IncrementalBuildResults)1 Module (org.guvnor.common.services.project.model.Module)1 Builder (org.kie.workbench.common.services.backend.builder.core.Builder)1 BuildInfo (org.kie.workbench.common.services.backend.builder.service.BuildInfo)1