elastic/elasticsearch · error · GradleException
Unnecessary split package ignores found
Error message
Unnecessary split package ignores found
What it means
Thrown by SplitPackagesAuditTask after iterating the per-project split-package ignore list. The audit walks every class on the classpath and removes each ignored FQCN from currentClasses; if remove() returns false the FQCN was not actually present, so the ignore entry is stale and filterErrorsFound flips true. The build then aborts with this message because the ignore list references classes that no longer exist in the audited project.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditTask.java:294
if (currentClasses == null) {
LOGGER.error("Package is not split: " + fqcn);
filterErrorsFound = true;
} else {
if (className.equals("*")) {
currentClasses.clear();
} else if (currentClasses.remove(fqcn) == false) {
LOGGER.error("Class does not exist: " + fqcn);
filterErrorsFound = true;
}
// cleanup if we have ignored the last class in a package
if (currentClasses.isEmpty()) {
splitPackages.remove(packageName);
}
}
}
if (filterErrorsFound) {
throw new GradleException("Unnecessary split package ignores found");
}
}
// TODO: want to read packages the same for src dirs and jars, but src dirs we also want the files in the src package dir
private static Set<String> readPackages(File classpathElement) {
Set<String> packages = new HashSet<>();
Consumer<Path> addClassPackage = p -> packages.add(getPackageName(p));
try {
if (classpathElement.isDirectory()) {
walkJavaFiles(classpathElement.toPath(), ".class", addClassPackage);
} else if (classpathElement.getName().endsWith(".jar")) {
try (FileSystem jar = FileSystems.newFileSystem(classpathElement.toPath(), Map.of())) {
for (Path root : jar.getRootDirectories()) {
walkJavaFiles(root, ".class", addClassPackage);
}
}
} else {View on GitHub (pinned to db6a809a66)
Solutions
- Locate the project's split-package ignore configuration (typically a splitPackagesAudit { ... } or ignore file referenced by the task) and remove the stale FQCN(s) that no longer exist.
- Re-run the task with --info to surface the 'Class does not exist:' log lines logged just before the throw, which name each offending FQCN.
- After editing, re-run ./gradlew :<project>:splitPackagesAudit (or the precommit task) to confirm the ignore list now matches reality.
Example fix
// before (stale entry in ignore list)
splitPackagesAudit {
ignore 'com.example.OldClassName'
}
// after (remove the deleted/renamed class)
splitPackagesAudit {
// entry removed — class no longer exists in this project
} Defensive patterns
Strategy: validation
Validate before calling
// Before the audit, verify every ignored FQCN still exists on the classpath
Set<String> ignoreList = loadSplitPackageIgnores(); // from config
Set<String> classesOnClasspath = collectFqcnFromCompiledOutput(projectOutputDir);
Set<String> stale = new HashSet<>(ignoreList);
stale.removeAll(classesOnClasspath);
if (stale.isEmpty() == false) {
throw new IllegalStateException("Remove stale ignores before running audit: " + stale);
} Prevention
- Treat the split-package ignore list as code: remove an ignore in the same PR that removes/renames the class.
- Run the precommit task locally before pushing so stale ignores surface early.
- Periodically grep ignore entries against the codebase and prune ones with zero matches.
When it happens
Trigger: A project's split-package ignore configuration lists a fully-qualified class name that has been renamed, moved, or deleted since the ignore was added. Running the splitPackagesAudit precommit task (directly or as part of check/precommit) removes existing classes from the set and, when a listed ignore cannot be matched against any current class, records an error and throws.
Common situations: Refactoring or relocating a class that was previously excluded from the split-package audit; merging a PR that deletes/moves a class without updating the ignore list; stale ignore entries left after a dependency upgrade changes shaded class names.
Related errors
- Third party audit task is not configured correctly
- Failed to create marker file
- Unsupported classpath element: {}
- Forbidden APIs cli failed: {forbiddenApisOutput}
- Failed to write keywords report
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/faf1892b5137a7eb.
Report an issue: GitHub.