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;
    }

    @InputFile

View on GitHub (pinned to c31c9215e1)

Solutions

  1. Set the property explicitly to your docs task output: kafkaPublicApiChecker.javadocJarPath = tasks.named('javadocJar', Jar).flatMap { it.archiveFile }.
  2. 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.
  3. If the project genuinely produces no javadoc (e.g. a bom/aggregator module), do not apply the public-api-checker plugin to it.
  4. 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

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


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