public static JibContainerBuilder toJibContainerBuilder(
      ArtifactProcessor processor,
      Jar jarOptions,
      CommonCliOptions commonCliOptions,
      CommonContainerConfigCliOptions commonContainerConfigCliOptions,
      ConsoleLogger logger)
      throws IOException, InvalidImageReferenceException {
    String imageReference =
        commonContainerConfigCliOptions.getFrom().orElseGet(() -> getDefaultBaseImage(processor));
    JibContainerBuilder containerBuilder =
        ContainerBuilders.create(imageReference, Collections.emptySet(), commonCliOptions, logger);

    List<FileEntriesLayer> layers = processor.createLayers();
    List<String> customEntrypoint = commonContainerConfigCliOptions.getEntrypoint();
    List<String> entrypoint =
        customEntrypoint.isEmpty()
            ? processor.computeEntrypoint(jarOptions.getJvmFlags())
            : customEntrypoint;

    containerBuilder
        .setEntrypoint(entrypoint)
        .setFileEntriesLayers(layers)
        .setExposedPorts(commonContainerConfigCliOptions.getExposedPorts())
        .setVolumes(commonContainerConfigCliOptions.getVolumes())
        .setEnvironment(commonContainerConfigCliOptions.getEnvironment())
        .setLabels(commonContainerConfigCliOptions.getLabels())
        .setProgramArguments(commonContainerConfigCliOptions.getProgramArguments());
    commonContainerConfigCliOptions.getUser().ifPresent(containerBuilder::setUser);
    commonContainerConfigCliOptions.getFormat().ifPresent(containerBuilder::setFormat);
    commonContainerConfigCliOptions.getCreationTime().ifPresent(containerBuilder::setCreationTime);

    return containerBuilder;
  }
@Test
  @Parameters(
      value = {
        "8, eclipse-temurin:8-jre",
        "9, eclipse-temurin:11-jre",
        "11, eclipse-temurin:11-jre",
        "13, eclipse-temurin:17-jre",
        "17, eclipse-temurin:17-jre",
        "21, eclipse-temurin:21-jre",
      })
  public void testToJibContainer_defaultBaseImage(int javaVersion, String expectedBaseImage)
      throws IOException, InvalidImageReferenceException {
    when(mockStandardExplodedProcessor.getJavaVersion()).thenReturn(javaVersion);
    JibContainerBuilder containerBuilder =
        JarFiles.toJibContainerBuilder(
            mockStandardExplodedProcessor,
            mockJarCommand,
            mockCommonCliOptions,
            mockCommonContainerConfigCliOptions,
            mockLogger);
    ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan();

    assertThat(buildPlan.getBaseImage()).isEqualTo(expectedBaseImage);
  }