apache/kafka · error · GradleException

No org.apache.kafka:* dependencies found on the configured k

Error message

No org.apache.kafka:* dependencies found on the configured kafkaDependencyJars. The checker cannot derive an API surface and would produce a meaningless '0 violations' report — likely a classpath or configuration issue.

What it means

Thrown by the Gradle KafkaInternalApiCheckerTask when failOnNoKafkaDependency is true and the kafkaDependencyJars file collection resolves to no org.apache.kafka artifacts. The checker needs those jars because the @InterfaceAudience.Public annotations on their classes define the legal API surface; without them it cannot distinguish public from internal types and would emit a misleading '0 violations'. Default is failOnNoKafkaDependency=false (warn-and-skip), so seeing this exception means a build script explicitly opted into the strict mode.

Source

Thrown at api-checker/gradle-plugins/src/main/java/org/apache/kafka/gradle/KafkaInternalApiCheckerTask.java:108

            return;
        }

        List<File> classRoots = PublicApiChecker.collectExistingRoots(classes.getFiles());
        if (classRoots.isEmpty()) {
            getLogger().info("No class files found, skipping internal API check");
            return;
        }

        runCheck(kafkaJars, classRoots);
    }

    private void handleNoKafkaDependency() {
        String msg = "No org.apache.kafka:* dependencies found on the configured "
                + "kafkaDependencyJars. The checker cannot derive an API surface and would "
                + "produce a meaningless '0 violations' report — likely a classpath or "
                + "configuration issue.";
        if (failOnNoKafkaDependency.get()) {
            throw new GradleException(msg);
        }
        getLogger().warn("{} Skipping internal API check. "
                + "Set kafkaInternalApiChecker.failOnNoKafkaDependency = true to make this fatal.", msg);
    }

    private void runCheck(List<File> kafkaJars, List<File> classRoots) {
        try {
            getLogger().info("Scanning {} class file root(s) for internal API usage", classRoots.size());
            CheckResult result = new PublicApiChecker(kafkaJars).checkBytecode(classRoots);
            reportResults(result);
        } catch (IOException e) {
            throw new GradleException("Failed to check internal API usage: " + e.getMessage(), e);
        }
    }

    private void reportResults(CheckResult result) throws IOException {
        List<PublicApiViolation> violations = result.violations();
        List<PublicApiViolation> suppressions = result.suppressions();

View on GitHub (pinned to c31c9215e1)

Solutions

  1. Add the Kafka dependency to the module, e.g. implementation 'org.apache.kafka:kafka-clients:3.8.0' (or kafka-streams), then re-run the task.
  2. If the dependency is provided transitively through a non-org.apache.kafka coordinate, explicitly wire it onto kafkaInternalApiChecker.kafkaDependencyJars.from(configurations.compileClasspath.filter { it.name.contains('kafka') }).
  3. If the module genuinely should not be checked, disable the task (kafkaInternalApiChecker.enabled = false) or remove the plugin from that subproject instead of leaving it running with no surface.
  4. Only as a last resort on a project that legitimately has no Kafka surface, keep failOnNoKafkaDependency = false (the default) so the check is skipped with a warning rather than failing the build.

Example fix

// before
kafkaInternalApiChecker {
  failOnNoKafkaDependency = true
}
// (module has no org.apache.kafka dependency)

// after — add the dependency the checker needs to derive the API surface
dependencies {
  implementation 'org.apache.kafka:kafka-clients:3.8.0'
}
Defensive patterns

Strategy: validation

Validate before calling

from release.notes import query

def has_issues_for_version(version):
    """Return True if at least one KAFKA issue is tagged with fixVersion=version."""
    issues = query(f"project=KAFKA and fixVersion={version}")
    return len(issues) > 0

# Caller-side guard before invoking generate(version):
if not has_issues_for_version(version):
    raise SystemExit(f"No issues found for version {version}; aborting release-notes generation.")
html = generate(version)

Try / catch

try:
    html = generate(version)
except Exception as e:
    if "Didn't find any issues for version" in str(e):
        # Empty/unreleased version: skip or fail gracefully
        sys.exit(f"Skipping {version}: no issues tagged.")
    raise  # re-raise unrelated errors

Prevention

When it happens

Trigger: KafkaInternalApiCheckerTask.handleNoKafkaDependency() at line 108 is reached when kafkaJars.isEmpty() (line 88) AND failOnNoKafkaDependency.get() returns true. The task is invoked (e.g. ./gradlew checkInternalApiUsage) on a project whose compile classpath contains no org.apache.kafka:* artifact, or whose plugin wiring (filtered to org.apache.kafka) resolved to nothing.

Common situations: A Kafka-dependent module that lost its kafka-clients/kafka-streams dependency after a refactor; a multi-module build where the plugin is applied to a subproject that uses a transitive Kafka dependency not captured by the org.apache.kafka filter; a freshly added module where the dependency declaration was forgotten; CI after a version coordinate change (e.g. switching groupId or using a shaded kafka jar).

Related errors


AI-assisted analysis of apache/kafka@c31c9215e1 (2026-08-03). Data as JSON: /data/errors/01eed2a0e07ccc12.json. Report an issue: GitHub.