elastic/elasticsearch · error · GradleException
expected [${noticePath} to contain [${expectedLine}] but it
Error message
expected [${noticePath} to contain [${expectedLine}] but it did not What it means
Thrown as GradleException inside the checkMlCppNotice task's doLast action when an expected license line from expectedMlLicenses is not present in the extracted x-pack-ml/NOTICE.txt. The check uses a sample of lines from the C++ notices as a proxy for full compliance — if those sample lines are missing, the notice is considered non-compliant.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveCheckPlugin.java:125
task.dependsOn(checkExtraction);
final Provider<Path> noticePath = checkExtraction.map(
c -> c.getDestinationDir()
.toPath()
.resolve("elasticsearch-" + VersionProperties.getElasticsearch() + "/modules/x-pack-ml/NOTICE.txt")
);
ListProperty<String> expectedMlLicenses = extension.expectedMlLicenses;
task.doLast(new Action<Task>() {
@Override
public void execute(Task task) {
// this is just a small sample from the C++ notices,
// the idea being that if we've added these lines we've probably added all the required lines
final List<String> expectedLines = expectedMlLicenses.get();
final List<String> actualLines;
try {
actualLines = Files.readAllLines(noticePath.get());
for (final String expectedLine : expectedLines) {
if (actualLines.contains(expectedLine) == false) {
throw new GradleException(
"expected [" + noticePath.get() + " to contain [" + expectedLine + "] but it did not"
);
}
}
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
});
});
return checkMlCppNoticeTask;
}
private TaskProvider<Task> registerCheckNoticeTask(Project project, TaskProvider<Copy> checkExtraction) {
return project.getTasks().register("checkNotice", task -> {
task.dependsOn(checkExtraction);
var noticePath = checkExtraction.map(
copy -> copy.getDestinationDir().toPath().resolve("elasticsearch-" + VersionProperties.getElasticsearch() + "/NOTICE.txt")View on GitHub (pinned to db6a809a66)
Solutions
- Diff the generated NOTICE.txt against the expected lines; add the missing license text to the ML notice generation source.
- Update distributionArchiveCheckExtension.expectedMlLicenses if the expected line content legitimately changed (dependency upgrade).
- Rebuild the distribution to regenerate NOTICE.txt before running checkMlCppNotice.
- Verify the x-pack-ml module is actually packaged and its NOTICE.txt is at the expected path.
Example fix
// before: expected line missing from NOTICE.txt
extension.expectedMlLicenses.add("Some Library 1.0 — BSD 2-Clause");
// NOTICE.txt lacks this exact line → throws
// after: add the line to the ML notice template/generator,
// or correct the expected string to match what ships
extension.expectedMlLicenses.add("Some Library 1.0 - BSD 2-Clause"); // match exact text Defensive patterns
Strategy: try-catch
Validate before calling
List<String> actual = Files.readAllLines(noticePath);
for (String expected : expectedMlLicenses) {
if (actual.contains(expected) == false) {
System.err.println("Missing ML notice line: " + expected);
}
} Try / catch
task.doLast(t -> {
try {
// check lines
} catch (Exception e) {
throw new GradleException("checkMlCppNotice failed: " + e.getMessage(), e);
}
}); Prevention
- Keep expectedMlLicenses in sync with ML dependency changes.
- Regenerate NOTICE.txt after adding C++ ML dependencies.
- Run checkMlCppNotice locally before pushing distribution changes.
- Review NOTICE.txt diffs in the ML module when upgrading dependencies.
When it happens
Trigger: The task (registered only for projects whose name contains 'zip' or 'tar', excluding integ-test-zip) reads NOTICE.txt from the extracted archive and checks each entry in extension.expectedMlLicenses via actualLines.contains(). A missing expected line throws at line 125.
Common situations: A new ML C++ dependency was added but its license line wasn't appended to NOTICE.txt generation; the notice file template changed; a dependency upgrade changed the upstream license text; the expectedMlLicenses extension was populated with outdated line content.
Related errors
- expected line [${line + 1}] in [${path}] to be [${expectedLi
- Two different notices exist for dependency '${name}': ${prev
- Unable to read from file ${path}
- Cannot set Elasticsearch Distribution type to ${type}. Type
- distribution type [${typeName}] for elasticsearch distributi
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/6cd3d09f4d414c1e.
Report an issue: GitHub.