Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.testing.Test;

import java.io.File;
import java.util.Arrays;
import java.util.List;

Expand All @@ -26,21 +27,22 @@ public class MutedTestPlugin implements Plugin<Project> {

@Override
public void apply(Project project) {
project.getRootProject().getPlugins().apply(GlobalBuildInfoPlugin.class);
var buildParams = loadBuildParams(project).get();

File settingsRoot = project.getLayout().getSettingsDirectory().getAsFile();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is getSettingsDirectory() now a recommended way to get a project root dir?
Could project.getRootProject().getRootDir() be used here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. In general accessing other projects from a project should be avoided. Gradle is more forgiving for rootProject but still not ideal.

String additionalFilePaths = project.hasProperty(ADDITIONAL_FILES_PROPERTY)
? project.property(ADDITIONAL_FILES_PROPERTY).toString()
: "";
List<RegularFile> additionalFiles = Arrays.stream(additionalFilePaths.split(","))
.filter(p -> p.isEmpty() == false)
.map(p -> project.getRootProject().getLayout().getProjectDirectory().file(p))
.map(p -> project.getLayout().getSettingsDirectory().file(p))
.toList();

project.getRootProject().getPlugins().apply(GlobalBuildInfoPlugin.class);
var buildParams = loadBuildParams(project).get();

Provider<MutedTestsBuildService> mutedTestsProvider = project.getGradle()
.getSharedServices()
.registerIfAbsent("mutedTests", MutedTestsBuildService.class, spec -> {
spec.getParameters().getInfoPath().set(project.getRootProject().getProjectDir());
spec.getParameters().getInfoPath().set(settingsRoot);
spec.getParameters().getAdditionalFiles().set(additionalFiles);
});

Expand Down
2 changes: 1 addition & 1 deletion test/external-modules/error-query/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies {
clusterModules project(':x-pack:plugin:ilm')
}

tasks.withType(StandaloneRestIntegTestTask) {
tasks.withType(StandaloneRestIntegTestTask).configureEach {
def isSnapshot = buildParams.snapshotBuild
onlyIf("snapshot build") { isSnapshot }
}