apache/kafka · error · GradleException

kafkaPublicApiChecker.javadocJarPath is not set. Either…

Error message

kafkaPublicApiChecker.javadocJarPath is not set. Either configure it explicitly on the extension, or apply this plugin to a project that defines a 'javadocJar' Jar task whose output the plugin can wire automatically.

What it means

GradleException from KafkaPublicApiCheckerTask.getJavadocJarFile when the javadocJarPath RegularFileProperty is not present. The plugin can auto-wire from a 'javadocJar' task, but if neither explicit configuration nor that task exists, it fails fast with a message describing both remediation paths.

Solutions

  1. Set javadocJarPath explicitly: kafkaPublicApiChecker.javadocJarPath = layout.buildDirectory.file('libs/foo-javadoc.jar').
  2. Ensure the 'java' plugin (and a javadocJar task) is applied so the plugin can auto-wire.
  3. If you have a differently named task, point javadocJarPath at its archiveFile: tasks.named('myJavadocJar').flatMap { it.archiveFile }.
  4. Add the task to the project: task javadocJar(type: Jar) { from javadoc; archiveClassifier = 'javadoc' }.

Example fix

// before — no javadocJar task, no explicit path
apply plugin: 'kafka-public-api-checker'
// after — explicit path
kafkaPublicApiChecker {
  javadocJarPath = layout.buildDirectory.file('libs/my-module-1.0-javadoc.jar')
}
Defensive patterns

Strategy: validation

Validate before calling

// In build.gradle
if (!plugins.hasPlugin('java')) apply plugin: 'java'
tasks.register('javadocJar', Jar) { archiveClassifier = 'javadoc'; from tasks.named('javadoc') }
// or set explicitly:
// kafkaPublicApiChecker.javadocJarPath = layout.buildDirectory.file('libs/foo-javadoc.jar')

Prevention

When it happens

Trigger: !javadocJarPath.isPresent() at line 137. Happens when the build script does not set kafkaPublicApiChecker.javadocJarPath AND the project has no 'javadocJar' Jar task for the plugin to wire automatically.

Common situations: Applying the plugin in a project that uses a custom doc task name; applying before the java plugin so no javadocJar task exists; shadowing/renaming the jar task.

Related errors


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

Appendix: source

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

                    violations.size(), report.getAbsolutePath());

                if (failOnViolation.get()) {
                    throw new GradleException(message);
                } else {
                    getLogger().warn(message);
                }
            } else {
                getLogger().info("No public API violations found.");
            }

        } catch (IOException e) {
            throw new GradleException("Failed to check public API: " + e.getMessage(), e);
        }
    }

    private File getJavadocJarFile() {
        if (!javadocJarPath.isPresent()) {
            throw new GradleException("kafkaPublicApiChecker.javadocJarPath is not set. "
                    + "Either configure it explicitly on the extension, or apply this plugin to a "
                    + "project that defines a 'javadocJar' Jar task whose output the plugin can "
                    + "wire automatically.");
        }
        return javadocJarPath.get().getAsFile();
    }

    @Input
    public Property<Boolean> getCheckerEnabled() {
        return enabled;
    }

    @Input
    public Property<Boolean> getFailOnViolation() {
        return failOnViolation;
    }

    @InputFile

View on GitHub (pinned to 996fb4585a)