Repository: GoogleContainerTools/jib
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/jar/JarProcessor.java (Java)

Code before:
   * @return list of {@link FileEntriesLayer}
   * @throws IOException if I/O error occurs when opening the jar file or if temporary directory
   *     provided doesn't exist
   */
  public static List<FileEntriesLayer> explodeStandardJar(Path jarPath, Path tempDirPath)
      throws IOException {
    Path localExplodedJarRoot = tempDirPath;
    ZipUtil.unzip(jarPath, localExplodedJarRoot);
    List<FileEntriesLayer> layers = new ArrayList<>();

    // Get dependencies from Class-Path in the jar's manifest and add a layer each for non-snapshot
    // and snapshot dependencies. If Class-Path is not present in the jar's manifest then skip
    // adding a dependencies layer.
    String classPath = null;
    try (JarFile jarFile = new JarFile(jarPath.toFile())) {
      classPath = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
    }

    if (classPath != null) {
      Predicate<String> isSnapshotDependency = name -> name.contains("SNAPSHOT");
      Predicate<String> isNotSnapshotDependency = isSnapshotDependency.negate();
      List<String> allDependencies = Splitter.onPattern("\\s+").splitToList(classPath.trim());
      List<Path> nonSnapshotDependencies =
          allDependencies
              .stream()
              .filter(isNotSnapshotDependency)
              .map(Paths::get)
              .collect(Collectors.toList());
      List<Path> snapshotDependencies =
          allDependencies
              .stream()
              .filter(isSnapshotDependency)
              .map(Paths::get)
              .collect(Collectors.toList());
      if (!nonSnapshotDependencies.isEmpty()) {
        FileEntriesLayer.Builder nonSnapshotDependenciesLayerBuilder =
            FileEntriesLayer.builder().setName("nonSnapshotDependencies");
        nonSnapshotDependencies.forEach(
            path ->
                nonSnapshotDependenciesLayerBuilder.addEntry(
                    path, APP_ROOT.resolve(RelativeUnixPath.get("dependencies")).resolve(path)));
        layers.add(nonSnapshotDependenciesLayerBuilder.build());
      }
      if (!snapshotDependencies.isEmpty()) {
        FileEntriesLayer.Builder snapshotDependenciesLayerBuilder =
            FileEntriesLayer.builder().setName("snapshotDependencies");
        snapshotDependencies.forEach(
            path ->
                snapshotDependenciesLayerBuilder.addEntry(
                    path, APP_ROOT.resolve(RelativeUnixPath.get("dependencies")).resolve(path)));
        layers.add(snapshotDependenciesLayerBuilder.build());

Review comment (suggestion):
I think it's okay to embed the predicate. And I think the name 'isSnapshot' is fine in this local scope.
```suggestion
              .filter(isSnapshot.negate())
```

Code after:
   * @return list of {@link FileEntriesLayer}
   * @throws IOException if I/O error occurs when opening the jar file or if temporary directory
   *     provided doesn't exist
   */
  public static List<FileEntriesLayer> explodeStandardJar(Path jarPath, Path tempDirPath)
      throws IOException {
    Path localExplodedJarRoot = tempDirPath;
    ZipUtil.unzip(jarPath, localExplodedJarRoot);
    List<FileEntriesLayer> layers = new ArrayList<>();

    // Get dependencies from Class-Path in the jar's manifest and add a layer each for non-snapshot
    // and snapshot dependencies. If Class-Path is not present in the jar's manifest then skip
    // adding a dependencies layer.
    String classPath = null;
    try (JarFile jarFile = new JarFile(jarPath.toFile())) {
      classPath = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
    }

    if (classPath != null) {
      Predicate<String> isSnapshot = name -> name.contains("SNAPSHOT");
      List<String> allDependencies = Splitter.onPattern("\\s+").splitToList(classPath.trim());
      List<Path> nonSnapshotDependencies =
          allDependencies
              .stream()
              .filter(isSnapshot.negate())
              .map(Paths::get)
              .collect(Collectors.toList());
      List<Path> snapshotDependencies =
          allDependencies.stream().filter(isSnapshot).map(Paths::get).collect(Collectors.toList());
      if (!nonSnapshotDependencies.isEmpty()) {
        FileEntriesLayer.Builder nonSnapshotDependenciesLayerBuilder =
            FileEntriesLayer.builder().setName("dependencies");
        nonSnapshotDependencies.forEach(
            path ->
                nonSnapshotDependenciesLayerBuilder.addEntry(
                    path, APP_ROOT.resolve(RelativeUnixPath.get("dependencies")).resolve(path)));
        layers.add(nonSnapshotDependenciesLayerBuilder.build());
      }
      if (!snapshotDependencies.isEmpty()) {
        FileEntriesLayer.Builder snapshotDependenciesLayerBuilder =
            FileEntriesLayer.builder().setName("snapshot dependencies");
        snapshotDependencies.forEach(
            path ->
                snapshotDependenciesLayerBuilder.addEntry(
                    path, APP_ROOT.resolve(RelativeUnixPath.get("dependencies")).resolve(path)));
        layers.add(snapshotDependenciesLayerBuilder.build());
      }
    }

    Predicate<Path> isClassFile = path -> path.getFileName().toString().endsWith(".class");
    Predicate<Path> isResourceFile = isClassFile.negate();