private void visitPaths(final DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream) {
    for (final org.uberfire.java.nio.file.Path path : directoryStream) {
      if (Files.isDirectory(path)) {
        visitPaths(Files.newDirectoryStream(path));

      } else {
        // Don't process dotFiles
        if (!dotFileFilter.accept(path)) {

          // Resource Type might require "external" validation (i.e. it's not covered by Kie)
          final BuildValidationHelper validator = getBuildValidationHelper(path);
          if (validator != null) {
            nonKieResourceValidationHelpers.put(path, validator);
          }

          // Add new resource
          final String destinationPath =
              path.toUri().toString().substring(projectPrefix.length() + 1);
          final InputStream is = ioService.newInputStream(path);
          final BufferedInputStream bis = new BufferedInputStream(is);
          kieFileSystem.write(
              destinationPath,
              KieServices.Factory.get().getResources().newInputStreamResource(bis));
          handles.put(getBaseFileName(destinationPath), Paths.convert(path));

          // Java classes are handled by KIE so we can safely post-process them here
          addJavaClass(path);
        }
      }
    }
  }
  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 IncrementalBuildResults addResource(final Path resource) {
    synchronized (kieFileSystem) {
      checkNotNull("resource", resource);

      // Only files can be processed
      if (!Files.isRegularFile(resource)) {
        return new IncrementalBuildResults(projectGAV);
      }

      checkAFullBuildHasBeenPerformed();

      // Resource Type might require "external" validation (i.e. it's not covered by Kie)
      final IncrementalBuildResults results = new IncrementalBuildResults(projectGAV);
      final BuildValidationHelper validator = getBuildValidationHelper(resource);
      if (validator != null) {
        final List<ValidationMessage> addedValidationMessages =
            validator.validate(Paths.convert(resource));

        results.addAllAddedMessages(convertValidationMessages(addedValidationMessages));
        results.addAllRemovedMessages(
            convertValidationMessages(nonKieResourceValidationHelperMessages.remove(resource)));

        nonKieResourceValidationHelpers.put(resource, validator);
        nonKieResourceValidationHelperMessages.put(resource, addedValidationMessages);
      }

      // Add new resource
      final String destinationPath =
          resource.toUri().toString().substring(projectPrefix.length() + 1);
      final InputStream is = ioService.newInputStream(resource);
      final BufferedInputStream bis = new BufferedInputStream(is);
      kieFileSystem.write(
          destinationPath, KieServices.Factory.get().getResources().newInputStreamResource(bis));
      addJavaClass(resource);
      handles.put(getBaseFileName(destinationPath), Paths.convert(resource));

      buildIncrementally(results, destinationPath);

      return results;
    }
  }
  private void update(
      final List<ValidationMessage> nonKieResourceValidatorAddedMessages,
      final List<ValidationMessage> nonKieResourceValidatorRemovedMessages,
      final Path resource,
      final String destinationPath) {
    // Resource Type might require "external" validation (i.e. it's not covered by Kie)
    final BuildValidationHelper validator = getBuildValidationHelper(resource);
    if (validator != null) {
      final List<ValidationMessage> addedValidationMessages =
          validator.validate(Paths.convert(resource));

      if (!(addedValidationMessages == null || addedValidationMessages.isEmpty())) {
        for (ValidationMessage validationMessage : addedValidationMessages) {
          nonKieResourceValidatorAddedMessages.add(validationMessage);
        }
      }

      final List<ValidationMessage> removedValidationMessages =
          nonKieResourceValidationHelperMessages.remove(resource);
      if (!(removedValidationMessages == null || removedValidationMessages.isEmpty())) {
        for (ValidationMessage validationMessage : removedValidationMessages) {
          nonKieResourceValidatorRemovedMessages.add(validationMessage);
        }
      }
      nonKieResourceValidationHelpers.put(resource, validator);
      nonKieResourceValidationHelperMessages.put(resource, addedValidationMessages);
    }

    // Add new resource
    final InputStream is = ioService.newInputStream(resource);
    final BufferedInputStream bis = new BufferedInputStream(is);
    kieFileSystem.write(
        destinationPath, KieServices.Factory.get().getResources().newInputStreamResource(bis));
    addJavaClass(resource);
    handles.put(getBaseFileName(destinationPath), Paths.convert(resource));
  }