Repository: GoogleContainerTools/jib
File: jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java (Java)

Code before:
    }

    if (projectProperties.getMajorJavaVersion() >= 9
        || rawConfiguration.getExpandClasspathDependencies()) {
      List<Path> jars = projectProperties.getDependencies();
      List<String> duplicates =
          jars.stream()
              .map(path -> path.getFileName().toString())
              .collect(Collectors.groupingBy(filename -> filename, Collectors.counting()))
              .entrySet()
              .stream()
              .filter(entry -> entry.getValue() > 1)
              .map(Map.Entry::getKey)
              .collect(Collectors.toList());

      for (Path jar : jars) {
        // Handle duplicates by appending filesize to the end of the file. This renaming logic
        // must be in sync with the code that does the same in the other place. See
        // https://github.com/GoogleContainerTools/jib/issues/3331
        String jarName = jar.getFileName().toString();
        if (duplicates.contains(jarName)) {
          jarName = jarName.replaceFirst("\\.jar$", "-" + Files.size(jar)) + ".jar";
        }
        classpath.add(appRoot.resolve("libs").resolve(jarName).toString());
      }
    } else {
      classpath.add(appRoot.resolve("libs/*").toString());
    }

    String classpathString = String.join(":", classpath);
    String mainClass;
    try {
      mainClass =
          MainClassResolver.resolveMainClass(
              rawConfiguration.getMainClass().orElse(null), projectProperties);
    } catch (MainClassInferenceException ex) {
      if (entrypointDefined) {
        // We will use the user-given entrypoint, so don't fail.
        mainClass = "could-not-infer-a-main-class";
      } else {
        throw ex;
      }
    }
    addJvmArgFilesLayer(
        rawConfiguration, projectProperties, jibContainerBuilder, classpathString, mainClass);

    if (projectProperties.getMajorJavaVersion() >= 9) {
      classpathString = "@" + appRoot.resolve(JIB_CLASSPATH_FILE);
    }

    if (entrypointDefined) {

Review comment (suggestion):
This situation is pretty rare but what if we end up with jars that are of the same size? How about we append incremented integers to jar name? Such as `jar-name-1.jar` and `jar-name-2.jar`. 

Code after:
    }

    if (projectProperties.getMajorJavaVersion() >= 9
        || rawConfiguration.getExpandClasspathDependencies()) {
      List<Path> jars = projectProperties.getDependencies();

      Map<String, Long> occurrences =
          jars.stream()
              .map(path -> path.getFileName().toString())
              .collect(Collectors.groupingBy(filename -> filename, Collectors.counting()));
      List<String> duplicates =
          occurrences
              .entrySet()
              .stream()
              .filter(entry -> entry.getValue() > 1)
              .map(Map.Entry::getKey)
              .collect(Collectors.toList());

      for (Path jar : jars) {
        // Handle duplicates by appending filesize to the end of the file. This renaming logic
        // must be in sync with the code that does the same in the other place. See
        // https://github.com/GoogleContainerTools/jib/issues/3331
        String jarName = jar.getFileName().toString();
        if (duplicates.contains(jarName)) {
          jarName = jarName.replaceFirst("\\.jar$", "-" + Files.size(jar)) + ".jar";
        }
        classpath.add(appRoot.resolve("libs").resolve(jarName).toString());
      }
    } else {
      classpath.add(appRoot.resolve("libs/*").toString());
    }

    String classpathString = String.join(":", classpath);
    String mainClass;
    try {
      mainClass =
          MainClassResolver.resolveMainClass(
              rawConfiguration.getMainClass().orElse(null), projectProperties);
    } catch (MainClassInferenceException ex) {
      if (entrypointDefined) {
        // We will use the user-given entrypoint, so don't fail.
        mainClass = "could-not-infer-a-main-class";
      } else {
        throw ex;
      }
    }
    addJvmArgFilesLayer(
        rawConfiguration, projectProperties, jibContainerBuilder, classpathString, mainClass);

    if (projectProperties.getMajorJavaVersion() >= 9) {
      classpathString = "@" + appRoot.resolve(JIB_CLASSPATH_FILE);