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
  public void testToJibContainerBuilder_packagedStandard_basicInfo()
      throws IOException, InvalidImageReferenceException {
    when(mockStandardPackagedProcessor.getJavaVersion()).thenReturn(8);
    FileEntriesLayer layer =
        FileEntriesLayer.builder()
            .setName("jar")
            .addEntry(
                Paths.get("path/to/standardJar.jar"), AbsoluteUnixPath.get("/app/standardJar.jar"))
            .build();
    when(mockStandardPackagedProcessor.createLayers()).thenReturn(Arrays.asList(layer));
    when(mockStandardPackagedProcessor.computeEntrypoint(anyList()))
        .thenReturn(ImmutableList.of("java", "-jar", "/app/standardJar.jar"));
    when(mockCommonContainerConfigCliOptions.getFrom()).thenReturn(Optional.empty());

    JibContainerBuilder containerBuilder =
        JarFiles.toJibContainerBuilder(
            mockStandardPackagedProcessor,
            mockJarCommand,
            mockCommonCliOptions,
            mockCommonContainerConfigCliOptions,
            mockLogger);
    ContainerBuildPlan buildPlan = containerBuilder.toContainerBuildPlan();

    assertThat(buildPlan.getBaseImage()).isEqualTo("eclipse-temurin:8-jre");
    assertThat(buildPlan.getPlatforms()).isEqualTo(ImmutableSet.of(new Platform("amd64", "linux")));
    assertThat(buildPlan.getCreationTime()).isEqualTo(Instant.EPOCH);
    assertThat(buildPlan.getFormat()).isEqualTo(ImageFormat.Docker);
    assertThat(buildPlan.getEnvironment()).isEmpty();
    assertThat(buildPlan.getLabels()).isEmpty();
    assertThat(buildPlan.getVolumes()).isEmpty();
    assertThat(buildPlan.getExposedPorts()).isEmpty();
    assertThat(buildPlan.getUser()).isNull();
    assertThat(buildPlan.getWorkingDirectory()).isNull();
    assertThat(buildPlan.getEntrypoint())
        .containsExactly("java", "-jar", "/app/standardJar.jar")
        .inOrder();
    assertThat(buildPlan.getLayers().get(0).getName()).isEqualTo("jar");
    assertThat(((FileEntriesLayer) buildPlan.getLayers().get(0)).getEntries())
        .isEqualTo(
            FileEntriesLayer.builder()
                .addEntry(
                    Paths.get("path/to/standardJar.jar"),
                    AbsoluteUnixPath.get("/app/standardJar.jar"))
                .build()
                .getEntries());
  }