Skip to content

Commit f173057

Browse files
authored
Removes DuplicateLayerException and does not add same layer consecutively. (#128)
* Removes DuplicateLayerException and does not add same layer consecutively. * Updates CHANGELOG. * Adds integration test for project with empty resources and dependencies.
1 parent b9c1566 commit f173057

30 files changed

+133
-116
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
88

99
### Fixed
1010
- Null tag validation generating NullPointerException ([#125](https://github.com/google/jib/issues/125))
11+
- Build failure on project with no dependencies ([#126](https://github.com/google/jib/issues/126))
1112

1213
## 0.1.3
1314
### Added

jib-core/src/main/java/com/google/cloud/tools/jib/builder/BuildAndPushContainerConfigurationStep.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.google.cloud.tools.jib.cache.CachedLayer;
2323
import com.google.cloud.tools.jib.hash.CountingDigestOutputStream;
2424
import com.google.cloud.tools.jib.http.Authorization;
25-
import com.google.cloud.tools.jib.image.DuplicateLayerException;
2625
import com.google.cloud.tools.jib.image.Image;
2726
import com.google.cloud.tools.jib.image.LayerPropertyNotFoundException;
2827
import com.google.cloud.tools.jib.image.json.ImageToJsonTranslator;
@@ -84,8 +83,8 @@ public ListenableFuture<BlobDescriptor> call() throws ExecutionException, Interr
8483
* {@code buildApplicationLayerFutures}.
8584
*/
8685
private BlobDescriptor afterBaseImageLayerFuturesFuture()
87-
throws ExecutionException, InterruptedException, LayerPropertyNotFoundException,
88-
DuplicateLayerException, IOException, RegistryException {
86+
throws ExecutionException, InterruptedException, LayerPropertyNotFoundException, IOException,
87+
RegistryException {
8988
try (Timer timer = new Timer(buildConfiguration.getBuildLogger(), DESCRIPTION)) {
9089
RegistryClient registryClient =
9190
new RegistryClient(

jib-core/src/main/java/com/google/cloud/tools/jib/builder/PullAndCacheBaseImageLayerStep.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.google.cloud.tools.jib.cache.CachedLayer;
2424
import com.google.cloud.tools.jib.http.Authorization;
2525
import com.google.cloud.tools.jib.image.DescriptorDigest;
26-
import com.google.cloud.tools.jib.image.DuplicateLayerException;
2726
import com.google.cloud.tools.jib.image.LayerPropertyNotFoundException;
2827
import com.google.cloud.tools.jib.registry.RegistryClient;
2928
import com.google.cloud.tools.jib.registry.RegistryException;
@@ -57,8 +56,8 @@ class PullAndCacheBaseImageLayerStep implements Callable<CachedLayer> {
5756
/** Depends on {@code pullAuthorizationFuture}. */
5857
@Override
5958
public CachedLayer call()
60-
throws IOException, RegistryException, LayerPropertyNotFoundException,
61-
DuplicateLayerException, ExecutionException, InterruptedException {
59+
throws IOException, RegistryException, LayerPropertyNotFoundException, ExecutionException,
60+
InterruptedException {
6261
try (Timer ignored =
6362
new Timer(buildConfiguration.getBuildLogger(), String.format(DESCRIPTION, layerDigest))) {
6463
RegistryClient registryClient =

jib-core/src/main/java/com/google/cloud/tools/jib/builder/PullBaseImageStep.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import com.google.cloud.tools.jib.Timer;
2020
import com.google.cloud.tools.jib.http.Authorization;
21-
import com.google.cloud.tools.jib.image.DuplicateLayerException;
2221
import com.google.cloud.tools.jib.image.Image;
2322
import com.google.cloud.tools.jib.image.LayerCountMismatchException;
2423
import com.google.cloud.tools.jib.image.LayerPropertyNotFoundException;
@@ -55,8 +54,7 @@ class PullBaseImageStep implements Callable<Image> {
5554
@Override
5655
public Image call()
5756
throws IOException, RegistryException, LayerPropertyNotFoundException,
58-
DuplicateLayerException, LayerCountMismatchException, ExecutionException,
59-
InterruptedException {
57+
LayerCountMismatchException, ExecutionException, InterruptedException {
6058
try (Timer ignored = new Timer(buildConfiguration.getBuildLogger(), DESCRIPTION)) {
6159
RegistryClient registryClient =
6260
new RegistryClient(

jib-core/src/main/java/com/google/cloud/tools/jib/builder/PushImageStep.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.google.cloud.tools.jib.blob.BlobDescriptor;
2121
import com.google.cloud.tools.jib.cache.CachedLayer;
2222
import com.google.cloud.tools.jib.http.Authorization;
23-
import com.google.cloud.tools.jib.image.DuplicateLayerException;
2423
import com.google.cloud.tools.jib.image.Image;
2524
import com.google.cloud.tools.jib.image.LayerPropertyNotFoundException;
2625
import com.google.cloud.tools.jib.image.json.BuildableManifestTemplate;
@@ -99,7 +98,7 @@ public Void call() throws ExecutionException, InterruptedException {
9998
*/
10099
private Void afterPushBaseImageLayerFuturesFuture()
101100
throws IOException, RegistryException, ExecutionException, InterruptedException,
102-
LayerPropertyNotFoundException, DuplicateLayerException {
101+
LayerPropertyNotFoundException {
103102
try (Timer ignored = new Timer(buildConfiguration.getBuildLogger(), DESCRIPTION)) {
104103
RegistryClient registryClient =
105104
new RegistryClient(

jib-core/src/main/java/com/google/cloud/tools/jib/cache/Cache.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.google.cloud.tools.jib.cache;
1818

1919
import com.google.cloud.tools.jib.cache.json.CacheMetadataTemplate;
20-
import com.google.cloud.tools.jib.image.DuplicateLayerException;
2120
import com.google.cloud.tools.jib.image.LayerPropertyNotFoundException;
2221
import com.google.cloud.tools.jib.json.JsonTemplateMapper;
2322
import com.google.common.annotations.VisibleForTesting;
@@ -85,7 +84,7 @@ public void close() throws IOException {
8584

8685
/** Adds the cached layer to the cache metadata. */
8786
void addLayerToMetadata(CachedLayer cachedLayer, @Nullable LayerMetadata layerMetadata)
88-
throws LayerPropertyNotFoundException, DuplicateLayerException {
87+
throws LayerPropertyNotFoundException {
8988
cacheMetadata.addLayer(new CachedLayerWithMetadata(cachedLayer, layerMetadata));
9089
}
9190

jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheMetadata.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.google.cloud.tools.jib.cache;
1818

19-
import com.google.cloud.tools.jib.image.DuplicateLayerException;
2019
import com.google.cloud.tools.jib.image.ImageLayers;
2120
import com.google.cloud.tools.jib.image.LayerPropertyNotFoundException;
2221
import java.nio.file.Path;
@@ -77,7 +76,7 @@ ImageLayers<CachedLayerWithMetadata> filter() throws CacheMetadataCorruptedExcep
7776

7877
return filteredLayers;
7978

80-
} catch (DuplicateLayerException | LayerPropertyNotFoundException ex) {
79+
} catch (LayerPropertyNotFoundException ex) {
8180
throw new CacheMetadataCorruptedException(ex);
8281
}
8382
}
@@ -87,8 +86,7 @@ ImageLayers<CachedLayerWithMetadata> getLayers() {
8786
return layers;
8887
}
8988

90-
synchronized void addLayer(CachedLayerWithMetadata layer)
91-
throws LayerPropertyNotFoundException, DuplicateLayerException {
89+
synchronized void addLayer(CachedLayerWithMetadata layer) throws LayerPropertyNotFoundException {
9290
layers.add(layer);
9391
}
9492

jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheMetadataTranslator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.google.cloud.tools.jib.cache.json.CacheMetadataLayerObjectTemplate;
2121
import com.google.cloud.tools.jib.cache.json.CacheMetadataLayerPropertiesObjectTemplate;
2222
import com.google.cloud.tools.jib.cache.json.CacheMetadataTemplate;
23-
import com.google.cloud.tools.jib.image.DuplicateLayerException;
2423
import com.google.cloud.tools.jib.image.LayerPropertyNotFoundException;
2524
import java.nio.file.Path;
2625

@@ -64,7 +63,7 @@ static CacheMetadata fromTemplate(CacheMetadataTemplate template, Path cacheDire
6463

6564
return cacheMetadata;
6665

67-
} catch (DuplicateLayerException | LayerPropertyNotFoundException ex) {
66+
} catch (LayerPropertyNotFoundException ex) {
6867
throw new CacheMetadataCorruptedException(ex);
6968
}
7069
}

jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheWriter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.google.cloud.tools.jib.blob.BlobDescriptor;
2020
import com.google.cloud.tools.jib.hash.CountingDigestOutputStream;
2121
import com.google.cloud.tools.jib.image.DescriptorDigest;
22-
import com.google.cloud.tools.jib.image.DuplicateLayerException;
2322
import com.google.cloud.tools.jib.image.LayerBuilder;
2423
import com.google.cloud.tools.jib.image.LayerPropertyNotFoundException;
2524
import com.google.cloud.tools.jib.image.UnwrittenLayer;
@@ -53,7 +52,7 @@ public CacheWriter(Cache cache) {
5352
* @return the cached layer
5453
*/
5554
public CachedLayer writeLayer(LayerBuilder layerBuilder)
56-
throws IOException, LayerPropertyNotFoundException, DuplicateLayerException {
55+
throws IOException, LayerPropertyNotFoundException {
5756
UnwrittenLayer unwrittenLayer = layerBuilder.build();
5857

5958
// Writes to a temporary file first because the UnwrittenLayer needs to be written first to
@@ -108,7 +107,7 @@ public CountingOutputStream getLayerOutputStream(DescriptorDigest layerDigest)
108107
*/
109108
public CachedLayer getCachedLayer(
110109
DescriptorDigest layerDigest, CountingOutputStream countingOutputStream)
111-
throws IOException, LayerPropertyNotFoundException, DuplicateLayerException {
110+
throws IOException, LayerPropertyNotFoundException {
112111
Path layerFile = getLayerFile(layerDigest);
113112
countingOutputStream.close();
114113

jib-core/src/main/java/com/google/cloud/tools/jib/image/DuplicateLayerException.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)