@VisibleForTesting
  static JibContainerBuilder processCommonConfiguration(
      RawConfiguration rawConfiguration,
      InferredAuthProvider inferredAuthProvider,
      ProjectProperties projectProperties)
      throws InvalidFilesModificationTimeException, InvalidAppRootException,
          IncompatibleBaseImageJavaVersionException, IOException, InvalidImageReferenceException,
          InvalidContainerizingModeException, MainClassInferenceException, InvalidPlatformException,
          InvalidContainerVolumeException, InvalidWorkingDirectoryException,
          InvalidCreationTimeException, ExtraDirectoryNotFoundException {

    // Create and configure JibContainerBuilder
    ModificationTimeProvider modificationTimeProvider =
        createModificationTimeProvider(rawConfiguration.getFilesModificationTime());
    JavaContainerBuilder javaContainerBuilder =
        getJavaContainerBuilderWithBaseImage(
                rawConfiguration, projectProperties, inferredAuthProvider)
            .setAppRoot(getAppRootChecked(rawConfiguration, projectProperties))
            .setModificationTimeProvider(modificationTimeProvider);
    JibContainerBuilder jibContainerBuilder =
        projectProperties.createJibContainerBuilder(
            javaContainerBuilder,
            getContainerizingModeChecked(rawConfiguration, projectProperties));
    jibContainerBuilder
        .setFormat(rawConfiguration.getImageFormat())
        .setPlatforms(getPlatformsSet(rawConfiguration))
        .setEntrypoint(computeEntrypoint(rawConfiguration, projectProperties, jibContainerBuilder))
        .setProgramArguments(rawConfiguration.getProgramArguments().orElse(null))
        .setEnvironment(rawConfiguration.getEnvironment())
        .setExposedPorts(Ports.parse(rawConfiguration.getPorts()))
        .setVolumes(getVolumesSet(rawConfiguration))
        .setLabels(rawConfiguration.getLabels())
        .setUser(rawConfiguration.getUser().orElse(null))
        .setCreationTime(getCreationTime(rawConfiguration.getCreationTime(), projectProperties));
    getWorkingDirectoryChecked(rawConfiguration)
        .ifPresent(jibContainerBuilder::setWorkingDirectory);

    // Adds all the extra files.
    for (ExtraDirectoriesConfiguration extraDirectory : rawConfiguration.getExtraDirectories()) {
      Path from = extraDirectory.getFrom();
      if (Files.exists(from)) {
        jibContainerBuilder.addFileEntriesLayer(
            JavaContainerBuilderHelper.extraDirectoryLayerConfiguration(
                from,
                AbsoluteUnixPath.get(extraDirectory.getInto()),
                extraDirectory.getIncludesList(),
                extraDirectory.getExcludesList(),
                rawConfiguration.getExtraDirectoryPermissions(),
                modificationTimeProvider));
      } else if (!from.endsWith(DEFAULT_JIB_DIR)) {
        throw new ExtraDirectoryNotFoundException(from.toString(), from.toString());
      }
    }
    return jibContainerBuilder;
  }
@Test
  public void testClasspathArgumentFile()
      throws NumberFormatException, InvalidImageReferenceException, MainClassInferenceException,
          InvalidAppRootException, IOException, InvalidWorkingDirectoryException,
          InvalidPlatformException, InvalidContainerVolumeException,
          IncompatibleBaseImageJavaVersionException, InvalidContainerizingModeException,
          InvalidFilesModificationTimeException, InvalidCreationTimeException,
          ExtraDirectoryNotFoundException {
    when(rawConfiguration.getExtraClasspath()).thenReturn(Collections.singletonList("/foo"));
    when(projectProperties.getMajorJavaVersion()).thenReturn(9);

    ContainerBuildPlan buildPlan = processCommonConfiguration();

    assertThat(buildPlan.getEntrypoint())
        .containsExactly("java", "-cp", "@/app/jib-classpath-file", "java.lang.Object")
        .inOrder();

    List<FileEntry> jvmArgFiles = getLayerEntries(buildPlan, "jvm arg files");
    assertThat(jvmArgFiles)
        .comparingElementsUsing(SOURCE_FILE_OF)
        .containsExactly(
            appCacheDirectory.resolve("jib-classpath-file"),
            appCacheDirectory.resolve("jib-main-class-file"));
    assertThat(jvmArgFiles)
        .comparingElementsUsing(EXTRACTION_PATH_OF)
        .containsExactly("/app/jib-classpath-file", "/app/jib-main-class-file");

    String classpath =
        new String(
            Files.readAllBytes(appCacheDirectory.resolve("jib-classpath-file")),
            StandardCharsets.UTF_8);
    assertThat(classpath)
        .isEqualTo("/foo:/app/resources:/app/classes:/app/libs/foo-1.jar:/app/libs/bar-2.jar");
    String mainClass =
        new String(
            Files.readAllBytes(appCacheDirectory.resolve("jib-main-class-file")),
            StandardCharsets.UTF_8);
    assertThat(mainClass).isEqualTo("java.lang.Object");
  }