apache/kafka · warning · GradleException

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

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 the kafkaDependencyJars file collection contains no org.apache.kafka:* artifacts. The checker needs those jars to derive the public/internal API surface; without them it would report a meaningless '0 violations'. The task only throws when failOnNoKafkaDependency is true (default false); otherwise it logs a warning and skips.

Solutions

  1. Wire the plugin: kafkaInternalApiChecker.kafkaDependencyJars.from(configurations.runtimeClasspath) (or the configuration that resolves kafka-clients) in build.gradle.
  2. Verify the artifact is actually org.apache.kafka:* — run ./gradlew dependencies on the relevant configuration and grep for the coordinate.
  3. If the module legitimately has no kafka dependency, set kafkaInternalApiChecker.failOnNoKafkaDependency = false (the default) so the task logs a warning and continues, or disable the task with enabled = false.
  4. If you want absence to be a hard error in CI, set failOnNoKafkaDependency = true and fix the wiring in step 1.

Example fix

// before
kafkaInternalApiChecker {
  classDirs = sourceSets.main.output.classesDirs
  // kafkaDependencyJars never wired -> no kafka artifacts found
}
// after
kafkaInternalApiChecker {
  classDirs = sourceSets.main.output.classesDirs
  kafkaDependencyJars.from(configurations.runtimeClasspath)
  failOnNoKafkaDependency = true
}
Defensive patterns

Strategy: validation

Validate before calling

// In build.gradle, before relying on the task
gradle.projectsEvaluated {
  tasks.matching { it.name == 'checkInternalApiUsage' }.configureEach {
    def kafkaCfg = configurations.matching { it.name.matches(/.*(classpath|compileClasspath|runtimeClasspath).*/) }
    if (kafkaCfg.collectMany { it.allDependencies }.every { it.group != 'org.apache.kafka' }) {
      logger.warn('kafkaInternalApiChecker: no org.apache.kafka dependency found; task will skip or fail per failOnNoKafkaDependency')
    }
  }
}

Prevention

When it happens

Trigger: Calling the checkInternalApiUsage task action when kafkaDependencyJars.getFiles() is empty (see line 88 check). The handler at line 107 throws GradleException only if the failOnNoKafkaDependency Property resolves to true. Happens when the build script never wires kafkaInternalApiChecker.kafkaDependencyJars to a configuration holding kafka-clients/kafka-server-common, or when the dependency was moved to a different configuration/coordinate.

Common situations: Newly applying the plugin without configuring kafkaDependencyJars; renaming the configuration that carries kafka artifacts; dependency declared as compileOnly/api in a way the checker's configuration does not extend; applying the plugin in a module that legitimately has no kafka dependency.

Related errors


AI-assisted analysis of apache/kafka@996fb4585a (2026-08-11). Data as JSON: /api/errors/01eed2a0e07ccc12. Report an issue: GitHub.

Appendix: 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 996fb4585a)