Search in sources :

Example 11 with Timer

use of com.google.cloud.tools.jib.Timer in project jib by google.

the class BuildAndCacheApplicationLayersStep method buildAndCacheLayerAsync.

private ListenableFuture<CachedLayer> buildAndCacheLayerAsync(String layerType, List<Path> sourceFiles, String extractionPath) {
    String description = "Building " + layerType + " layer";
    return listeningExecutorService.submit(() -> {
        try (Timer ignored = new Timer(buildConfiguration.getBuildLogger(), description)) {
            // Don't build the layer if it exists already.
            CachedLayer cachedLayer = new CacheReader(cache).getUpToDateLayerBySourceFiles(sourceFiles);
            if (cachedLayer != null) {
                return cachedLayer;
            }
            LayerBuilder layerBuilder = new LayerBuilder(sourceFiles, extractionPath, buildConfiguration.getEnableReproducibleBuilds());
            cachedLayer = new CacheWriter(cache).writeLayer(layerBuilder);
            // TODO: Remove
            buildConfiguration.getBuildLogger().debug(description + " built " + cachedLayer.getBlobDescriptor().getDigest());
            return cachedLayer;
        }
    });
}
Also used : Timer(com.google.cloud.tools.jib.Timer) LayerBuilder(com.google.cloud.tools.jib.image.LayerBuilder) CacheWriter(com.google.cloud.tools.jib.cache.CacheWriter) CachedLayer(com.google.cloud.tools.jib.cache.CachedLayer) CacheReader(com.google.cloud.tools.jib.cache.CacheReader)

Example 12 with Timer

use of com.google.cloud.tools.jib.Timer in project jib by google.

the class BuildAndCacheApplicationLayersStep method call.

/**
 * Depends on nothing.
 */
@Override
public List<ListenableFuture<CachedLayer>> call() {
    try (Timer ignored = new Timer(buildConfiguration.getBuildLogger(), DESCRIPTION)) {
        List<ListenableFuture<CachedLayer>> applicationLayerFutures = new ArrayList<>(3);
        applicationLayerFutures.add(buildAndCacheLayerAsync("dependencies", sourceFilesConfiguration.getDependenciesFiles(), sourceFilesConfiguration.getDependenciesPathOnImage()));
        applicationLayerFutures.add(buildAndCacheLayerAsync("resources", sourceFilesConfiguration.getResourcesFiles(), sourceFilesConfiguration.getResourcesPathOnImage()));
        applicationLayerFutures.add(buildAndCacheLayerAsync("classes", sourceFilesConfiguration.getClassesFiles(), sourceFilesConfiguration.getClassesPathOnImage()));
        return applicationLayerFutures;
    }
}
Also used : Timer(com.google.cloud.tools.jib.Timer) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Aggregations

Timer (com.google.cloud.tools.jib.Timer)12 CachedLayer (com.google.cloud.tools.jib.cache.CachedLayer)6 RegistryClient (com.google.cloud.tools.jib.registry.RegistryClient)5 Authorization (com.google.cloud.tools.jib.http.Authorization)4 Image (com.google.cloud.tools.jib.image.Image)3 CacheReader (com.google.cloud.tools.jib.cache.CacheReader)2 CacheWriter (com.google.cloud.tools.jib.cache.CacheWriter)2 ImageToJsonTranslator (com.google.cloud.tools.jib.image.json.ImageToJsonTranslator)2 RegistryAuthenticator (com.google.cloud.tools.jib.registry.RegistryAuthenticator)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 Nullable (javax.annotation.Nullable)2 Blob (com.google.cloud.tools.jib.blob.Blob)1 BlobDescriptor (com.google.cloud.tools.jib.blob.BlobDescriptor)1 Cache (com.google.cloud.tools.jib.cache.Cache)1 Caches (com.google.cloud.tools.jib.cache.Caches)1 CountingDigestOutputStream (com.google.cloud.tools.jib.hash.CountingDigestOutputStream)1 DescriptorDigest (com.google.cloud.tools.jib.image.DescriptorDigest)1 LayerBuilder (com.google.cloud.tools.jib.image.LayerBuilder)1 BuildableManifestTemplate (com.google.cloud.tools.jib.image.json.BuildableManifestTemplate)1 ContainerConfigurationTemplate (com.google.cloud.tools.jib.image.json.ContainerConfigurationTemplate)1