elastic/elasticsearch · error · InvalidUserDataException

elasticsearch.standalone-test, elasticsearch.standalone-rest

Error message

elasticsearch.standalone-test, elasticsearch.standalone-rest-test, and elasticsearch.build are mutually exclusive

What it means

Thrown by BuildPlugin.apply (the elasticsearch.build plugin) when elasticsearch.standalone-rest-test is already applied to the same project. The three plugin families - elasticsearch.build, elasticsearch.standalone-test, and elasticsearch.standalone-rest-test - are mutually exclusive because each fully configures a project for a different purpose; mixing them double-configures the project.

Source

Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BuildPlugin.java:57

    private final BuildLayout buildLayout;
    private final ObjectFactory objectFactory;
    private final ProviderFactory providerFactory;
    private final ProjectLayout projectLayout;

    @Inject
    BuildPlugin(BuildLayout buildLayout, ObjectFactory objectFactory, ProviderFactory providerFactory, ProjectLayout projectLayout) {
        this.buildLayout = buildLayout;
        this.objectFactory = objectFactory;
        this.providerFactory = providerFactory;
        this.projectLayout = projectLayout;
    }

    @Override
    public void apply(final Project project) {
        // make sure the global build info plugin is applied to the root project
        project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class);
        if (project.getPluginManager().hasPlugin("elasticsearch.standalone-rest-test")) {
            throw new InvalidUserDataException(
                "elasticsearch.standalone-test, " + "elasticsearch.standalone-rest-test, and elasticsearch.build are mutually exclusive"
            );
        }

        project.getPluginManager().apply("elasticsearch.java");
        project.getPluginManager().apply(ElasticsearchJavadocPlugin.class);
        project.getPluginManager().apply(DependenciesInfoPlugin.class);
        project.getPluginManager().apply(LicensingPlugin.class);
        project.getPluginManager().apply(SnykDependencyMonitoringGradlePlugin.class);
        project.getPluginManager().apply(ClusterFeaturesMetadataPlugin.class);
        InternalPrecommitTasks.create(project, true);
        configureLicenseAndNotice(project);
    }

    public void configureLicenseAndNotice(final Project project) {
        final ExtraPropertiesExtension ext = project.getExtensions().getByType(ExtraPropertiesExtension.class);
        RegularFileProperty licenseFileProperty = objectFactory.fileProperty();
        RegularFileProperty noticeFileProperty = objectFactory.fileProperty();

View on GitHub (pinned to db6a809a66)

Solutions

  1. Remove the conflicting plugin apply so only one of the three is present.
  2. Decide the module type: production code -> elasticsearch.build; standalone JVM tests -> standalone-test; REST test -> standalone-rest-test.
  3. Check for transitive plugin application via a convention plugin that pulls in both.

Example fix

// before
apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.build'
// after
apply plugin: 'elasticsearch.build'
Defensive patterns

Strategy: validation

Validate before calling

if (project.getPluginManager().hasPlugin("elasticsearch.standalone-rest-test")) {
    throw new InvalidUserDataException(
        "elasticsearch.standalone-test, elasticsearch.standalone-rest-test, and elasticsearch.build are mutually exclusive"
    );
}

Prevention

When it happens

Trigger: Applying apply plugin: 'elasticsearch.build' to a project whose build.gradle already contains apply plugin: 'elasticsearch.standalone-rest-test' (or standalone-test).

Common situations: Copy-pasting a plugin block from a server subproject into a test subproject; misclassifying whether a module is a main build, standalone test, or REST test.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/c7ebb9211c83315d. Report an issue: GitHub.