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;
}
});
}
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;
}
}
Aggregations