Skip to content

Commit

Permalink
Avoid eagerly resolving dependencies when configuring packaging tests (
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira authored Nov 14, 2023
1 parent 9dd483b commit 9a50817
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void apply(Project project) {
addDistributionSysprop(t, DISTRIBUTION_SYSPROP, distribution::getFilepath);
addDistributionSysprop(t, EXAMPLE_PLUGIN_SYSPROP, () -> examplePlugin.getSingleFile().toString());
t.exclude("**/PackageUpgradeTests.class");
}, distribution.getArchiveDependencies(), examplePlugin.getDependencies());
}, distribution, examplePlugin.getDependencies());

if (distribution.getPlatform() == Platform.WINDOWS) {
windowsTestTasks.add(destructiveTask);
Expand Down Expand Up @@ -235,6 +235,7 @@ private static ElasticsearchDistribution createDistro(
d.setBundledJdk(bundledJdk);
}
d.setVersion(version);
d.setPreferArchive(true);
});

// Allow us to gracefully omit building Docker distributions if Docker is not available on the system.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public String toString() {
private final Property<Platform> platform;
private final Property<Boolean> bundledJdk;
private final Property<Boolean> failIfUnavailable;
private final Property<Boolean> preferArchive;
private final ConfigurableFileCollection extracted;
private Action<ElasticsearchDistribution> distributionFinalizer;
private boolean frozen = false;
Expand All @@ -75,6 +76,7 @@ public String toString() {
this.platform = objectFactory.property(Platform.class);
this.bundledJdk = objectFactory.property(Boolean.class);
this.failIfUnavailable = objectFactory.property(Boolean.class).convention(true);
this.preferArchive = objectFactory.property(Boolean.class).convention(false);
this.extracted = extractedConfiguration;
this.distributionFinalizer = distributionFinalizer;
}
Expand Down Expand Up @@ -141,6 +143,14 @@ public void setFailIfUnavailable(boolean failIfUnavailable) {
this.failIfUnavailable.set(failIfUnavailable);
}

public boolean getPreferArchive() {
return preferArchive.get();
}

public void setPreferArchive(boolean preferArchive) {
this.preferArchive.set(preferArchive);
}

public void setArchitecture(Architecture architecture) {
this.architecture.set(architecture);
}
Expand Down Expand Up @@ -188,7 +198,9 @@ public TaskDependency getBuildDependencies() {
return task -> Collections.emptySet();
} else {
maybeFreeze();
return getType().shouldExtract() ? extracted.getBuildDependencies() : configuration.getBuildDependencies();
return getType().shouldExtract() && (preferArchive.get() == false)
? extracted.getBuildDependencies()
: configuration.getBuildDependencies();
}
}

Expand Down Expand Up @@ -253,13 +265,4 @@ void finalizeValues() {
type.finalizeValue();
bundledJdk.finalizeValue();
}

public TaskDependency getArchiveDependencies() {
if (skippingDockerDistributionBuild()) {
return task -> Collections.emptySet();
} else {
maybeFreeze();
return configuration.getBuildDependencies();
}
}
}

0 comments on commit 9a50817

Please sign in to comment.