2525import com .google .cloud .tools .jib .cache .CacheReader ;
2626import com .google .cloud .tools .jib .cache .CacheWriter ;
2727import com .google .cloud .tools .jib .cache .CachedLayerWithMetadata ;
28+ import com .google .cloud .tools .jib .image .LayerEntry ;
2829import com .google .cloud .tools .jib .image .ReproducibleLayerBuilder ;
2930import com .google .common .collect .ImmutableList ;
3031import com .google .common .util .concurrent .ListenableFuture ;
3132import com .google .common .util .concurrent .ListeningExecutorService ;
3233import java .io .IOException ;
33- import java .nio .file .Path ;
3434import java .util .concurrent .Callable ;
3535
3636/** Builds and caches application layers. */
@@ -54,30 +54,35 @@ static ImmutableList<BuildAndCacheApplicationLayerStep> makeList(
5454 "dependencies" ,
5555 listeningExecutorService ,
5656 buildConfiguration ,
57- sourceFilesConfiguration .getDependenciesFiles (),
58- sourceFilesConfiguration .getDependenciesPathOnImage (),
57+ ImmutableList .of (
58+ new LayerEntry (
59+ sourceFilesConfiguration .getDependenciesFiles (),
60+ sourceFilesConfiguration .getDependenciesPathOnImage ())),
5961 cache ),
6062 new BuildAndCacheApplicationLayerStep (
6163 "resources" ,
6264 listeningExecutorService ,
6365 buildConfiguration ,
64- sourceFilesConfiguration .getResourcesFiles (),
65- sourceFilesConfiguration .getResourcesPathOnImage (),
66+ ImmutableList .of (
67+ new LayerEntry (
68+ sourceFilesConfiguration .getResourcesFiles (),
69+ sourceFilesConfiguration .getResourcesPathOnImage ())),
6670 cache ),
6771 new BuildAndCacheApplicationLayerStep (
6872 "classes" ,
6973 listeningExecutorService ,
7074 buildConfiguration ,
71- sourceFilesConfiguration .getClassesFiles (),
72- sourceFilesConfiguration .getClassesPathOnImage (),
75+ ImmutableList .of (
76+ new LayerEntry (
77+ sourceFilesConfiguration .getClassesFiles (),
78+ sourceFilesConfiguration .getClassesPathOnImage ())),
7379 cache ));
7480 }
7581 }
7682
7783 private final String layerType ;
7884 private final BuildConfiguration buildConfiguration ;
79- private final ImmutableList <Path > sourceFiles ;
80- private final String extractionPath ;
85+ private final ImmutableList <LayerEntry > layerEntries ;
8186 private final Cache cache ;
8287
8388 private final ListenableFuture <CachedLayerWithMetadata > listenableFuture ;
@@ -86,13 +91,11 @@ private BuildAndCacheApplicationLayerStep(
8691 String layerType ,
8792 ListeningExecutorService listeningExecutorService ,
8893 BuildConfiguration buildConfiguration ,
89- ImmutableList <Path > sourceFiles ,
90- String extractionPath ,
94+ ImmutableList <LayerEntry > layerEntries ,
9195 Cache cache ) {
9296 this .layerType = layerType ;
9397 this .buildConfiguration = buildConfiguration ;
94- this .sourceFiles = sourceFiles ;
95- this .extractionPath = extractionPath ;
98+ this .layerEntries = layerEntries ;
9699 this .cache = cache ;
97100
98101 listenableFuture = listeningExecutorService .submit (this );
@@ -112,13 +115,16 @@ public CachedLayerWithMetadata call() throws IOException, CacheMetadataCorrupted
112115 try (Timer ignored = new Timer (buildConfiguration .getBuildLogger (), description )) {
113116 // Don't build the layer if it exists already.
114117 CachedLayerWithMetadata cachedLayer =
115- new CacheReader (cache ).getUpToDateLayerBySourceFiles ( sourceFiles );
118+ new CacheReader (cache ).getUpToDateLayerByLayerEntries ( layerEntries );
116119 if (cachedLayer != null ) {
117120 return cachedLayer ;
118121 }
119122
120- ReproducibleLayerBuilder reproducibleLayerBuilder =
121- new ReproducibleLayerBuilder ().addFiles (sourceFiles , extractionPath );
123+ ReproducibleLayerBuilder reproducibleLayerBuilder = new ReproducibleLayerBuilder ();
124+ for (LayerEntry layerEntry : layerEntries ) {
125+ reproducibleLayerBuilder .addFiles (
126+ layerEntry .getSourceFiles (), layerEntry .getExtractionPath ());
127+ }
122128
123129 cachedLayer = new CacheWriter (cache ).writeLayer (reproducibleLayerBuilder );
124130
0 commit comments