Repository: GoogleContainerTools/jib
File: jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java (Java)

Code before:
      return javaContainerBuilder.toContainerBuilder();

    } catch (IOException ex) {
      throw new GradleException("Obtaining project build output files failed", ex);
    }
  }

  @Override
  public List<Path> getClassFiles() throws IOException {
    // TODO: Consolidate with createJibContainerBuilder
    FileCollection classesOutputDirectories =
        getMainSourceSet().getOutput().getClassesDirs().filter(File::exists);
    List<Path> classFiles = new ArrayList<>();
    for (File classesOutputDirectory : classesOutputDirectories) {
      classFiles.addAll(new DirectoryWalker(classesOutputDirectory.toPath()).walk().asList());
    }
    return classFiles;
  }

  @Override
  public List<Path> getDependencies() {
    List<Path> dependencies = new ArrayList<>();
    FileCollection runtimeClasspath = project.getConfigurations().getByName(configurationName);
    // To be on the safe side with the order, calling "forEach" first (no filtering operations).
    runtimeClasspath
        .getAsFileTree()
        .forEach(
            file -> {
              if (file.exists()
                  && file.isFile()
                  && file.getName().toLowerCase(Locale.US).endsWith(".jar")) {
                dependencies.add(file.toPath());
              }
            });
    return dependencies;
  }

  @Override
  public void waitForLoggingThread() {
    singleThreadedExecutor.shutDownAndAwaitTermination(LOGGING_THREAD_SHUTDOWN_TIMEOUT);
  }

  @Override
  public void configureEventHandlers(Containerizer containerizer) {
    containerizer
        .addEventHandler(LogEvent.class, this::log)
        .addEventHandler(
            TimerEvent.class, new TimerEventHandler(message -> log(LogEvent.debug(message))))
        .addEventHandler(
            ProgressEvent.class,
            new ProgressEventHandler(

Review comment (suggestion):
`getAsFileTree()`: what does this do and why do we want to add this? Can you guarantee this does not change the current behavior? The order of the elements in the return value is important (that's why we have the code comment right above), but the [Javadoc](https://docs.gradle.org/current/javadoc/org/gradle/api/file/FileTree.html) of `FileTree` says

> The order of the files in a `FileTree` is not stable, even on a single computer.

Code after:
    }
  }

  @Override
  public List<Path> getClassFiles() throws IOException {
    // TODO: Consolidate with createJibContainerBuilder
    FileCollection classesOutputDirectories =
        getMainSourceSet().getOutput().getClassesDirs().filter(File::exists);
    List<Path> classFiles = new ArrayList<>();
    for (File classesOutputDirectory : classesOutputDirectories) {
      classFiles.addAll(new DirectoryWalker(classesOutputDirectory.toPath()).walk().asList());
    }
    return classFiles;
  }

  @Override
  public List<Path> getDependencies() {
    List<Path> dependencies = new ArrayList<>();
    FileCollection runtimeClasspath = project.getConfigurations().getByName(configurationName);
    // To be on the safe side with the order, calling "forEach" first (no filtering operations).
    runtimeClasspath.forEach(
        file -> {
          if (file.exists()
              && file.isFile()
              && file.getName().toLowerCase(Locale.US).endsWith(".jar")) {
            dependencies.add(file.toPath());
          }
        });
    return dependencies;
  }

  @Override
  public void waitForLoggingThread() {
    singleThreadedExecutor.shutDownAndAwaitTermination(LOGGING_THREAD_SHUTDOWN_TIMEOUT);
  }

  @Override
  public void configureEventHandlers(Containerizer containerizer) {
    containerizer
        .addEventHandler(LogEvent.class, this::log)
        .addEventHandler(
            TimerEvent.class, new TimerEventHandler(message -> log(LogEvent.debug(message))))
        .addEventHandler(
            ProgressEvent.class,
            new ProgressEventHandler(
                update -> {
                  List<String> footer =
                      ProgressDisplayGenerator.generateProgressDisplay(
                          update.getProgress(), update.getUnfinishedLeafTasks());
                  footer.add("");
                  consoleLogger.setFooter(footer);