apache/kafka · error · GradleException
kafkaPublicApiChecker.javadocJarPath is not set. Either conf
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
Thrown by KafkaPublicApiCheckerTask.getJavadocJarFile() when the javadocJarPath RegularFileProperty has no value (isPresent() is false). Unlike projectJarFiles, javadocJarPath has no convention default — it must be set either explicitly on the extension or implicitly by applying the plugin to a project that defines a javadocJar Jar task the plugin can auto-wire. The message lists both ways to satisfy the requirement.
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;
}
@InputFileView on GitHub (pinned to c31c9215e1)
Solutions
- Set the property explicitly to your docs task output: kafkaPublicApiChecker.javadocJarPath = tasks.named('javadocJar', Jar).flatMap { it.archiveFile }.
- If your docs task is named differently (e.g. docsJar), alias or rename it to javadocJar so the plugin's auto-wiring picks it up, or just point the property at the renamed task's archiveFile.
- If the project genuinely produces no javadoc (e.g. a bom/aggregator module), do not apply the public-api-checker plugin to it.
- Add a dependsOn so the docs task actually runs before the check: tasks.named('kafkaPublicApiCheck').dependsOn('javadocJar').
Example fix
// before
plugins { id 'org.apache.kafka.kafka-public-api-checker' }
// javadocJarPath not set -> exception
// after
plugins { id 'org.apache.kafka.kafka-public-api-checker' }
kafkaPublicApiChecker {
javadocJarPath = tasks.named('javadocJar', Jar).flatMap { it.archiveFile }
}
tasks.named('kafkaPublicApiCheck').configure { dependsOn('javadocJar') } Defensive patterns
Strategy: validation
Validate before calling
// Set javadocJarPath explicitly, or ensure a 'javadocJar' Jar task exists for the plugin to wire
tasks.named<org.apache.kafka.gradle.KafkaPublicApiCheckerTask>("kafkaPublicApiChecker").configure {
javadocJarPath.set(tasks.named<Jar>("javadocJar").get().archiveFile)
}
// Or register the task if your project lacks it
if (tasks.findByName("javadocJar") == null) {
tasks.register<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
from(tasks.named("javadoc").get().outputs)
}
} Type guard
fun RegularFileProperty?.resolvedOrThrow(taskName: String): File =
this?.takeIf { it.isPresent }?.get()?.asFile
?: error("Set kafkaPublicApiChecker.javadocJarPath or apply the plugin to a project with a '$taskName' Jar task") Prevention
- Configure kafkaPublicApiChecker.javadocJarPath in the same block that applies the plugin — don't rely on the project already defining javadocJar.
- If your project has no javadoc task, register a javadocJar Jar task (classifier 'javadoc') before applying the checker.
- Add a configuration-time assertion: javadocJarPath.isPresent must be true, or the build fails early with a clear message instead of at task execution.
When it happens
Trigger: Line 136-141: javadocJarPath.isPresent() is false. Reached at the start of checkPublicApi() when neither auto-wiring (no javadocJar task in the project) nor an explicit configuration populated the property — e.g. plugin applied to a project whose docs task is named differently (docsJar, sourcesAndDocs), or applied without any docs task at all.
Common situations: Applying the plugin to a project that has no javadocJar task; a project where the docs task was renamed (docsJar) and the plugin's auto-wire logic only matches 'javadocJar'; a build that sets the property inside a conditional that didn't fire (e.g. only in if (JavaVersion.current().isJava11Compatible()){}).
Related errors
- No org.apache.kafka:* dependencies found on the configured k
- Javadoc JAR file not found: {path}. Make sure the javadoc ta
- No project JARs configured on kafkaPublicApiChecker.projectJ
- Found %d public API violations. See report: %s
- Failed to check internal API usage: {errorMessage}
AI-assisted analysis of apache/kafka@c31c9215e1 (2026-08-03).
Data as JSON: /data/errors/7d9a2c37ae3e9444.json.
Report an issue: GitHub.