iemejia commented on a change in pull request #14520:
URL: https://github.com/apache/beam/pull/14520#discussion_r612935409



##########
File path: 
runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/resources/PipelineResources.java
##########
@@ -64,6 +70,31 @@
     return resourcePath -> !resourcePath.contains("gradle/wrapper");
   }
 
+  /**
+   * Goes through the list of files that need to be staged on runner. Removes 
nonexistent
+   * directories and packages existing ones. This is necessary for runners 
that require filesToStage
+   * to be jars only.
+   *
+   * @param options options object with the files to stage and temp location 
for staging
+   */
+  public static void prepareFilesForStaging(FileStagingOptions options) {
+    List<String> filesToStage = options.getFilesToStage();
+    if (filesToStage == null || filesToStage.isEmpty()) {
+      filesToStage = 
detectClassPathResourcesToStage(ReflectHelpers.findClassLoader(), options);
+      LOG.info(
+          "PipelineOptions.filesToStage was not specified. "
+              + "Defaulting to files from the classpath: will stage {} files. "
+              + "Enable logging at DEBUG level to see which files will be 
staged.",
+          filesToStage.size());
+      LOG.debug("Classpath elements: {}", filesToStage);
+    }
+    options.setFilesToStage(
+        PipelineResources.prepareFilesForStaging(

Review comment:
       Sure, my goal was to offer the equivalent functionality for the ones who 
wanted to do the mutation explictly but since everybody should rely on the 
other method I will merge both.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to