@Override
  public PreparedLayer call() throws IOException, CacheCorruptedException {
    String description = String.format(DESCRIPTION, layerName);

    EventHandlers eventHandlers = buildContext.getEventHandlers();
    eventHandlers.dispatch(LogEvent.progress(description + "..."));

    try (ProgressEventDispatcher ignored =
            progressEventDispatcherFactory.create("building " + layerName + " layer", 1);
        TimerEventDispatcher ignored2 = new TimerEventDispatcher(eventHandlers, description)) {
      Cache cache = buildContext.getApplicationLayersCache();

      ImmutableList<FileEntry> layerEntries = ImmutableList.copyOf(layerConfiguration.getEntries());
      // Don't build the layer if it exists already.
      Optional<CachedLayer> optionalCachedLayer = cache.retrieve(layerEntries);
      if (optionalCachedLayer.isPresent()) {
        return new PreparedLayer.Builder(optionalCachedLayer.get()).setName(layerName).build();
      }

      Blob layerBlob = new ReproducibleLayerBuilder(layerEntries).build();
      CachedLayer cachedLayer = cache.writeUncompressedLayer(layerBlob, layerEntries);

      eventHandlers.dispatch(LogEvent.debug(description + " built " + cachedLayer.getDigest()));

      return new PreparedLayer.Builder(cachedLayer).setName(layerName).build();
    }
  }
Makes a list of {@link BuildAndCacheApplicationLayerStep} for dependencies, resources, and
classes layers. Optionally adds an extra layer if configured to do so.
jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/BuildAndCacheApplicationLayerStep.java