|
31 | 31 | import java.util.Collections;
|
32 | 32 | import java.util.Iterator;
|
33 | 33 | import java.util.Locale;
|
| 34 | +import java.util.Optional; |
34 | 35 | import java.util.function.Function;
|
35 | 36 |
|
36 | 37 | public class ElasticsearchDistribution implements Buildable, Iterable<File> {
|
@@ -205,7 +206,7 @@ public String toString() {
|
205 | 206 | * if not executed before, this
|
206 | 207 | * freezes the distribution configuration and
|
207 | 208 | * runs distribution finalizer logic.
|
208 |
| - * */ |
| 209 | + */ |
209 | 210 | public ElasticsearchDistribution maybeFreeze() {
|
210 | 211 | if (!froozen) {
|
211 | 212 | finalizeValues();
|
@@ -237,25 +238,31 @@ public Configuration getExtracted() {
|
237 | 238 |
|
238 | 239 | @Override
|
239 | 240 | public TaskDependency getBuildDependencies() {
|
240 |
| - // For non-required Docker distributions, skip building the distribution is Docker is unavailable |
241 |
| - if (isDocker() && getFailIfUnavailable() == false && dockerSupport.get().getDockerAvailability().isAvailable == false) { |
242 |
| - return task -> Collections.emptySet(); |
243 |
| - } |
244 |
| - maybeFreeze(); |
245 |
| - return getType().shouldExtract() ? extracted.getBuildDependencies() : configuration.getBuildDependencies(); |
| 241 | + Optional<TaskDependency> dockerBuildDependencies = dockerBuildDependencies(); |
| 242 | + return dockerBuildDependencies.orElseGet(() -> { |
| 243 | + maybeFreeze(); |
| 244 | + return getType().shouldExtract() ? extracted.getBuildDependencies() : configuration.getBuildDependencies(); |
| 245 | + }); |
246 | 246 | }
|
247 | 247 |
|
248 | 248 | public TaskDependency getArchiveBuildDependencies() {
|
| 249 | + Optional<TaskDependency> dockerBuildDependencies = dockerBuildDependencies(); |
| 250 | + return dockerBuildDependencies.orElseGet(() -> { |
| 251 | + maybeFreeze(); |
| 252 | + return configuration.getBuildDependencies(); |
| 253 | + }); |
| 254 | + } |
| 255 | + |
| 256 | + private Optional<TaskDependency> dockerBuildDependencies() { |
249 | 257 | // For non-required Docker distributions, skip building the distribution is Docker is unavailable
|
250 |
| - if (isDocker() && getFailIfUnavailable() == false && dockerSupport.get().getDockerAvailability().isAvailable == false) { |
251 |
| - return task -> Collections.emptySet(); |
252 |
| - } |
253 |
| - maybeFreeze(); |
254 |
| - return configuration.getBuildDependencies(); |
| 258 | + return (isDocker() && getFailIfUnavailable() == false && dockerSupport.get().getDockerAvailability().isAvailable == false) |
| 259 | + ? Optional.of(task -> Collections.emptySet()) |
| 260 | + : Optional.empty(); |
255 | 261 | }
|
256 | 262 |
|
257 | 263 | @Override
|
258 | 264 | public Iterator<File> iterator() {
|
| 265 | + maybeFreeze(); |
259 | 266 | return getType().shouldExtract() ? extracted.iterator() : configuration.iterator();
|
260 | 267 | }
|
261 | 268 |
|
|
0 commit comments