code: public static void copyResources(final MavenProject project, final MavenSession session,
                                       final MavenResourcesFiltering filtering, final List<Resource> resources,
                                       final String targetDirectory) throws IOException {
          for (final Resource resource : resources) {
              final String targetPath = resource.getTargetPath() == null ? "" : resource.getTargetPath();
              resource.setTargetPath(Paths.get(targetDirectory, targetPath).toString());
              resource.setFiltering(false);
          }
  
          final MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution(
              resources,
              new File(targetDirectory),
              project,
              "UTF-8",
              null,
              Collections.EMPTY_LIST,
              session
          );
  
          // Configure executor
          mavenResourcesExecution.setEscapeWindowsPaths(true);
          mavenResourcesExecution.setInjectProjectBuildFilters(false);
          mavenResourcesExecution.setOverwrite(true);
          mavenResourcesExecution.setIncludeEmptyDirs(false);
          mavenResourcesExecution.setSupportMultiLineFiltering(false);
  
          // Filter resources
          try {
              filtering.filterResources(mavenResourcesExecution);
          } catch (MavenFilteringException ex) {
              throw new IOException("Failed to copy resources", ex);
          }
      }
docs: Copy resources to target directory using Maven resource filtering so that we don't have to handle
  recursive directory listing and pattern matching.
  In order to disable filtering, the "filtering" property is force set to False.
  
  @param project
  @param session
  @param filtering
  @param resources
  @param targetDirectory
  @throws IOException