elastic/elasticsearch · error · GradleException

No dependencies variable defined.

Error message

No dependencies variable defined.

What it means

Thrown by DependencyLicensesTask.checkDependencies() when the dependencies field is null at task-action time. The task cross-checks declared dependencies against LICENSE files; without the dependencies configuration attached it cannot run. It is a wiring/config error — the task was registered without setting the dependencies variable that the parent AbstractDependenciesTask exposes.

Source

Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/DependencyLicensesTask.java:189

        ignoreShas.add(dep);
    }

    /**
     * Add a file that should be ignored by the check. This should be used for additional license files not tied to jar dependency
     */
    public void ignoreFile(String file) {
        ignoreFiles.add(file);
    }

    @Input
    @Optional
    public abstract Property<Spec<ComponentIdentifier>> getComponentFilter();

    @TaskAction
    public void checkDependencies() {
        collectedProblems = new ArrayList<>();
        if (dependencies == null) {
            throw new GradleException("No dependencies variable defined.");
        }
        File licensesDirAsFile = licensesDir.get().getAsFile();
        if (dependencies.isEmpty()) {
            if (licensesDirAsFile.exists() && allIgnored() == false) {
                reportProblem(
                    "no-dependencies",
                    "Licenses dir exists without dependencies",
                    "Licenses dir " + licensesDirAsFile + " exists, but there are no dependencies",
                    "Remove the licenses directory or add dependencies"
                );
            }
            throwIfProblems();
            return; // no dependencies to check
        } else if (licensesDirAsFile.exists() == false) {
            String deps = dependencies.getFiles().stream().map(File::getName).collect(Collectors.joining("\n"));
            reportProblem(
                "missing-licenses-dir",
                "Licenses directory missing",

View on GitHub (pinned to db6a809a66)

Solutions

  1. Find the dependencyLicenses task registration and confirm it is set up through the project's dependencies helper (the helper populates the variable).
  2. If the module genuinely has no external dependencies, remove the dependencyLicenses task (and its LICENSES dir) rather than leave it half-wired.
  3. Re-run the task to confirm.
Defensive patterns

Strategy: validation

Validate before calling

// After registering the task, confirm dependencies is populated
DependencyLicensesTask t = tasks.named('dependencyLicenses', DependencyLicensesTask).get();
if (t.dependencies == null) throw new InvalidUserDataException("dependencyLicenses needs the 'dependencies' helper to be called");

Prevention

When it happens

Trigger: A dependencyLicenses task registration that never calls the wiring that populates the dependencies variable (typically via the dependencies helper from AbstractDependenciesTask), so it stays null.

Common situations: A subproject that defines a dependencyLicenses task but has no 'dependencies' block / helper invocation; a refactor that dropped the setup; a project with no external deps that still registers the task.

Related errors


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