38
38
* @author Andrey Shlykov
39
39
* @author Jeroen Meijer
40
40
* @author Rafael Ceccone
41
+ * @author Julian Liebig
41
42
* @since 2.3.0
42
43
*/
43
44
public class BuildRequest {
@@ -74,6 +75,10 @@ public class BuildRequest {
74
75
75
76
private final List <ImageReference > tags ;
76
77
78
+ private final Cache buildCache ;
79
+
80
+ private final Cache launchCache ;
81
+
77
82
BuildRequest (ImageReference name , Function <Owner , TarArchive > applicationContent ) {
78
83
Assert .notNull (name , "Name must not be null" );
79
84
Assert .notNull (applicationContent , "ApplicationContent must not be null" );
@@ -91,12 +96,14 @@ public class BuildRequest {
91
96
this .bindings = Collections .emptyList ();
92
97
this .network = null ;
93
98
this .tags = Collections .emptyList ();
99
+ this .buildCache = null ;
100
+ this .launchCache = null ;
94
101
}
95
102
96
103
BuildRequest (ImageReference name , Function <Owner , TarArchive > applicationContent , ImageReference builder ,
97
104
ImageReference runImage , Creator creator , Map <String , String > env , boolean cleanCache ,
98
105
boolean verboseLogging , PullPolicy pullPolicy , boolean publish , List <BuildpackReference > buildpacks ,
99
- List <Binding > bindings , String network , List <ImageReference > tags ) {
106
+ List <Binding > bindings , String network , List <ImageReference > tags , Cache buildCache , Cache launchCache ) {
100
107
this .name = name ;
101
108
this .applicationContent = applicationContent ;
102
109
this .builder = builder ;
@@ -111,6 +118,8 @@ public class BuildRequest {
111
118
this .bindings = bindings ;
112
119
this .network = network ;
113
120
this .tags = tags ;
121
+ this .buildCache = buildCache ;
122
+ this .launchCache = launchCache ;
114
123
}
115
124
116
125
/**
@@ -122,7 +131,7 @@ public BuildRequest withBuilder(ImageReference builder) {
122
131
Assert .notNull (builder , "Builder must not be null" );
123
132
return new BuildRequest (this .name , this .applicationContent , builder .inTaggedOrDigestForm (), this .runImage ,
124
133
this .creator , this .env , this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish ,
125
- this .buildpacks , this .bindings , this .network , this .tags );
134
+ this .buildpacks , this .bindings , this .network , this .tags , this . buildCache , this . launchCache );
126
135
}
127
136
128
137
/**
@@ -133,7 +142,7 @@ public BuildRequest withBuilder(ImageReference builder) {
133
142
public BuildRequest withRunImage (ImageReference runImageName ) {
134
143
return new BuildRequest (this .name , this .applicationContent , this .builder , runImageName .inTaggedOrDigestForm (),
135
144
this .creator , this .env , this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish ,
136
- this .buildpacks , this .bindings , this .network , this .tags );
145
+ this .buildpacks , this .bindings , this .network , this .tags , this . buildCache , this . launchCache );
137
146
}
138
147
139
148
/**
@@ -145,7 +154,7 @@ public BuildRequest withCreator(Creator creator) {
145
154
Assert .notNull (creator , "Creator must not be null" );
146
155
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , creator , this .env ,
147
156
this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish , this .buildpacks , this .bindings ,
148
- this .network , this .tags );
157
+ this .network , this .tags , this . buildCache , this . launchCache );
149
158
}
150
159
151
160
/**
@@ -161,7 +170,7 @@ public BuildRequest withEnv(String name, String value) {
161
170
env .put (name , value );
162
171
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator ,
163
172
Collections .unmodifiableMap (env ), this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish ,
164
- this .buildpacks , this .bindings , this .network , this .tags );
173
+ this .buildpacks , this .bindings , this .network , this .tags , this . buildCache , this . launchCache );
165
174
}
166
175
167
176
/**
@@ -175,7 +184,8 @@ public BuildRequest withEnv(Map<String, String> env) {
175
184
updatedEnv .putAll (env );
176
185
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator ,
177
186
Collections .unmodifiableMap (updatedEnv ), this .cleanCache , this .verboseLogging , this .pullPolicy ,
178
- this .publish , this .buildpacks , this .bindings , this .network , this .tags );
187
+ this .publish , this .buildpacks , this .bindings , this .network , this .tags , this .buildCache ,
188
+ this .launchCache );
179
189
}
180
190
181
191
/**
@@ -186,7 +196,7 @@ public BuildRequest withEnv(Map<String, String> env) {
186
196
public BuildRequest withCleanCache (boolean cleanCache ) {
187
197
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
188
198
cleanCache , this .verboseLogging , this .pullPolicy , this .publish , this .buildpacks , this .bindings ,
189
- this .network , this .tags );
199
+ this .network , this .tags , this . buildCache , this . launchCache );
190
200
}
191
201
192
202
/**
@@ -197,7 +207,7 @@ public BuildRequest withCleanCache(boolean cleanCache) {
197
207
public BuildRequest withVerboseLogging (boolean verboseLogging ) {
198
208
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
199
209
this .cleanCache , verboseLogging , this .pullPolicy , this .publish , this .buildpacks , this .bindings ,
200
- this .network , this .tags );
210
+ this .network , this .tags , this . buildCache , this . launchCache );
201
211
}
202
212
203
213
/**
@@ -208,7 +218,7 @@ public BuildRequest withVerboseLogging(boolean verboseLogging) {
208
218
public BuildRequest withPullPolicy (PullPolicy pullPolicy ) {
209
219
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
210
220
this .cleanCache , this .verboseLogging , pullPolicy , this .publish , this .buildpacks , this .bindings ,
211
- this .network , this .tags );
221
+ this .network , this .tags , this . buildCache , this . launchCache );
212
222
}
213
223
214
224
/**
@@ -219,7 +229,7 @@ public BuildRequest withPullPolicy(PullPolicy pullPolicy) {
219
229
public BuildRequest withPublish (boolean publish ) {
220
230
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
221
231
this .cleanCache , this .verboseLogging , this .pullPolicy , publish , this .buildpacks , this .bindings ,
222
- this .network , this .tags );
232
+ this .network , this .tags , this . buildCache , this . launchCache );
223
233
}
224
234
225
235
/**
@@ -243,7 +253,7 @@ public BuildRequest withBuildpacks(List<BuildpackReference> buildpacks) {
243
253
Assert .notNull (buildpacks , "Buildpacks must not be null" );
244
254
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
245
255
this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish , buildpacks , this .bindings ,
246
- this .network , this .tags );
256
+ this .network , this .tags , this . buildCache , this . launchCache );
247
257
}
248
258
249
259
/**
@@ -267,7 +277,7 @@ public BuildRequest withBindings(List<Binding> bindings) {
267
277
Assert .notNull (bindings , "Bindings must not be null" );
268
278
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
269
279
this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish , this .buildpacks , bindings ,
270
- this .network , this .tags );
280
+ this .network , this .tags , this . buildCache , this . launchCache );
271
281
}
272
282
273
283
/**
@@ -279,7 +289,7 @@ public BuildRequest withBindings(List<Binding> bindings) {
279
289
public BuildRequest withNetwork (String network ) {
280
290
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
281
291
this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish , this .buildpacks , this .bindings ,
282
- network , this .tags );
292
+ network , this .tags , this . buildCache , this . launchCache );
283
293
}
284
294
285
295
/**
@@ -301,7 +311,31 @@ public BuildRequest withTags(List<ImageReference> tags) {
301
311
Assert .notNull (tags , "Tags must not be null" );
302
312
return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
303
313
this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish , this .buildpacks , this .bindings ,
304
- this .network , tags );
314
+ this .network , tags , this .buildCache , this .launchCache );
315
+ }
316
+
317
+ /**
318
+ * Return a new {@link BuildRequest} with an updated build cache.
319
+ * @param buildCache the build cache
320
+ * @return an updated build request
321
+ */
322
+ public BuildRequest withBuildCache (Cache buildCache ) {
323
+ Assert .notNull (buildCache , "BuildCache must not be null" );
324
+ return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
325
+ this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish , this .buildpacks , this .bindings ,
326
+ this .network , this .tags , buildCache , this .launchCache );
327
+ }
328
+
329
+ /**
330
+ * Return a new {@link BuildRequest} with an updated launch cache.
331
+ * @param launchCache the cache
332
+ * @return an updated build request
333
+ */
334
+ public BuildRequest withLaunchCache (Cache launchCache ) {
335
+ Assert .notNull (launchCache , "LaunchCache must not be null" );
336
+ return new BuildRequest (this .name , this .applicationContent , this .builder , this .runImage , this .creator , this .env ,
337
+ this .cleanCache , this .verboseLogging , this .pullPolicy , this .publish , this .buildpacks , this .bindings ,
338
+ this .network , this .tags , this .buildCache , launchCache );
305
339
}
306
340
307
341
/**
@@ -421,6 +455,22 @@ public List<ImageReference> getTags() {
421
455
return this .tags ;
422
456
}
423
457
458
+ /**
459
+ * Return the custom build cache that should be used by the lifecycle.
460
+ * @return the build cache
461
+ */
462
+ public Cache getBuildCache () {
463
+ return this .buildCache ;
464
+ }
465
+
466
+ /**
467
+ * Return the custom launch cache that should be used by the lifecycle.
468
+ * @return the launch cache
469
+ */
470
+ public Cache getLaunchCache () {
471
+ return this .launchCache ;
472
+ }
473
+
424
474
/**
425
475
* Factory method to create a new {@link BuildRequest} from a JAR file.
426
476
* @param jarFile the source jar file
0 commit comments