private void buildIncrementally(
      final IncrementalBuildResults results, final String... destinationPath) {
    try {
      final IncrementalResults incrementalResults =
          ((InternalKieBuilder) kieBuilder).createFileSet(destinationPath).build();
      results.addAllAddedMessages(convertMessages(incrementalResults.getAddedMessages(), handles));
      results.addAllRemovedMessages(
          convertMessages(incrementalResults.getRemovedMessages(), handles));

      // Tidy-up removed message handles
      for (Message message : incrementalResults.getRemovedMessages()) {
        handles.remove(Handles.RESOURCE_PATH + "/" + getBaseFileName(message.getPath()));
      }

    } catch (LinkageError e) {
      final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, e.getLocalizedMessage());
      logger.warn(msg);
      results.addAddedMessage(makeWarningMessage(msg));

    } catch (Throwable e) {
      final String msg = e.getLocalizedMessage();
      logger.error(msg, e);
      results.addAddedMessage(makeErrorMessage(msg));
    }
  }
  public BuildResults build() {
    synchronized (kieFileSystem) {
      // KieBuilder is not re-usable for successive "full" builds
      kieBuilder = createKieBuilder(kieFileSystem);

      // Record RTEs from KieBuilder - that can fail if a rule uses an inaccessible class
      final BuildResults results = new BuildResults(projectGAV);
      try {
        final Results kieResults = kieBuilder.buildAll().getResults();
        results.addAllBuildMessages(convertMessages(kieResults.getMessages(), handles));

      } catch (LinkageError e) {
        final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, e.getLocalizedMessage());
        logger.warn(msg);
        results.addBuildMessage(makeWarningMessage(msg));

      } catch (Throwable e) {
        final String msg = e.getLocalizedMessage();
        logger.error(msg, e);
        results.addBuildMessage(makeErrorMessage(msg));

      } finally {
        pomModelCache.setEntry(project, ((KieBuilderImpl) kieBuilder).getPomModel());
      }

      // Add validate messages from external helpers
      for (Map.Entry<Path, BuildValidationHelper> e : nonKieResourceValidationHelpers.entrySet()) {
        final org.uberfire.backend.vfs.Path vfsPath = Paths.convert(e.getKey());
        final List<ValidationMessage> validationMessages = e.getValue().validate(vfsPath);
        nonKieResourceValidationHelperMessages.put(e.getKey(), validationMessages);
        results.addAllBuildMessages(convertValidationMessages(validationMessages));
      }

      // Check external imports are available. These are loaded when a DMO is requested, but it's
      // better to report them early
      final org.uberfire.java.nio.file.Path nioExternalImportsPath =
          projectRoot.resolve("project.imports");
      if (Files.exists(nioExternalImportsPath)) {
        final org.uberfire.backend.vfs.Path externalImportsPath =
            Paths.convert(nioExternalImportsPath);
        final ProjectImports projectImports = importsService.load(externalImportsPath);
        final Imports imports = projectImports.getImports();
        for (final Import item : imports.getImports()) {
          final String fullyQualifiedClassName = item.getType();
          try {
            Class clazz = this.getClass().getClassLoader().loadClass(item.getType());

          } catch (ClassNotFoundException cnfe) {
            logger.warn(cnfe.getMessage());
            final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, fullyQualifiedClassName);
            results.addBuildMessage(makeWarningMessage(msg));
          }
        }
      }

      // At the end we are interested to ensure that external .jar files referenced as dependencies
      // don't have
      // referential inconsistencies. We will at least provide a basic algorithm to ensure that if
      // an external class
      // X references another external class Y, Y is also accessible by the class loader.
      final KieModuleMetaData kieModuleMetaData =
          KieModuleMetaData.Factory.newKieModuleMetaData(
              ((InternalKieBuilder) kieBuilder).getKieModuleIgnoringErrors());
      final Set<String> packageNamesWhiteList =
          packageNameWhiteList.filterPackageNames(project, kieModuleMetaData.getPackages());
      // store the project dependencies ClassLoader for optimization purposes.
      updateDependenciesClassLoader(project, kieModuleMetaData);

      for (final String packageName : kieModuleMetaData.getPackages()) {
        if (packageNamesWhiteList.contains(packageName)) {
          for (final String className : kieModuleMetaData.getClasses(packageName)) {
            final String fullyQualifiedClassName = packageName + "." + className;
            try {
              final Class clazz = kieModuleMetaData.getClass(packageName, className);
              if (clazz != null) {
                final TypeSource typeSource = getClassSource(kieModuleMetaData, clazz);
                if (TypeSource.JAVA_DEPENDENCY == typeSource) {
                  verifyExternalClass(clazz);
                }
              } else {
                final String msg =
                    MessageFormat.format(ERROR_EXTERNAL_CLASS_VERIFICATON, fullyQualifiedClassName);
                logger.warn(msg);
              }

            } catch (Throwable e) {
              final String msg =
                  MessageFormat.format(ERROR_EXTERNAL_CLASS_VERIFICATON, fullyQualifiedClassName);
              logger.warn(msg);
              results.addBuildMessage(makeWarningMessage(msg));
            }
          }
        }
      }

      return results;
    }
  }