{"record":{"id":"d8a415740d50a4bb","repo":"elastic/elasticsearch","slug":"no-dependencies-variable-defined","errorCode":null,"errorMessage":"No dependencies variable defined.","messagePattern":"No dependencies variable defined\\.","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/DependencyLicensesTask.java","lineNumber":189,"sourceCode":"        ignoreShas.add(dep);\n    }\n\n    /**\n     * Add a file that should be ignored by the check. This should be used for additional license files not tied to jar dependency\n     */\n    public void ignoreFile(String file) {\n        ignoreFiles.add(file);\n    }\n\n    @Input\n    @Optional\n    public abstract Property<Spec<ComponentIdentifier>> getComponentFilter();\n\n    @TaskAction\n    public void checkDependencies() {\n        collectedProblems = new ArrayList<>();\n        if (dependencies == null) {\n            throw new GradleException(\"No dependencies variable defined.\");\n        }\n        File licensesDirAsFile = licensesDir.get().getAsFile();\n        if (dependencies.isEmpty()) {\n            if (licensesDirAsFile.exists() && allIgnored() == false) {\n                reportProblem(\n                    \"no-dependencies\",\n                    \"Licenses dir exists without dependencies\",\n                    \"Licenses dir \" + licensesDirAsFile + \" exists, but there are no dependencies\",\n                    \"Remove the licenses directory or add dependencies\"\n                );\n            }\n            throwIfProblems();\n            return; // no dependencies to check\n        } else if (licensesDirAsFile.exists() == false) {\n            String deps = dependencies.getFiles().stream().map(File::getName).collect(Collectors.joining(\"\\n\"));\n            reportProblem(\n                \"missing-licenses-dir\",\n                \"Licenses directory missing\",","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/DependencyLicensesTask.java#L171-L207","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Find the dependencyLicenses task registration and confirm it is set up through the project's dependencies helper (the helper populates the variable).","If the module genuinely has no external dependencies, remove the dependencyLicenses task (and its LICENSES dir) rather than leave it half-wired.","Re-run the task to confirm."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// After registering the task, confirm dependencies is populated\nDependencyLicensesTask t = tasks.named('dependencyLicenses', DependencyLicensesTask).get();\nif (t.dependencies == null) throw new InvalidUserDataException(\"dependencyLicenses needs the 'dependencies' helper to be called\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set up dependencyLicenses via the project's dependencies helper so the variable is populated.","If a module has no external deps, remove the task and its LICENSES dir instead of leaving it half-wired.","Audit task setup when refactoring dependency declarations."],"tags":["gradle","dependency-licenses","precommit","task-config"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}