{"id":"7d9a2c37ae3e9444","repo":"apache/kafka","slug":"kafkapublicapichecker-javadocjarpath-is-not-set-e","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"api-checker/gradle-plugins/src/main/java/org/apache/kafka/gradle/KafkaPublicApiCheckerTask.java","lineNumber":137,"sourceCode":"                    violations.size(), report.getAbsolutePath());\n\n                if (failOnViolation.get()) {\n                    throw new GradleException(message);\n                } else {\n                    getLogger().warn(message);\n                }\n            } else {\n                getLogger().info(\"No public API violations found.\");\n            }\n\n        } catch (IOException e) {\n            throw new GradleException(\"Failed to check public API: \" + e.getMessage(), e);\n        }\n    }\n\n    private File getJavadocJarFile() {\n        if (!javadocJarPath.isPresent()) {\n            throw new GradleException(\"kafkaPublicApiChecker.javadocJarPath is not set. \"\n                    + \"Either configure it explicitly on the extension, or apply this plugin to a \"\n                    + \"project that defines a 'javadocJar' Jar task whose output the plugin can \"\n                    + \"wire automatically.\");\n        }\n        return javadocJarPath.get().getAsFile();\n    }\n\n    @Input\n    public Property<Boolean> getCheckerEnabled() {\n        return enabled;\n    }\n\n    @Input\n    public Property<Boolean> getFailOnViolation() {\n        return failOnViolation;\n    }\n\n    @InputFile","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/kafka/blob/c31c9215e131f8c17e79f8901b48c13ee6aa8e7a/api-checker/gradle-plugins/src/main/java/org/apache/kafka/gradle/KafkaPublicApiCheckerTask.java#L119-L155","documentation":"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.","triggerScenarios":"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.","commonSituations":"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()){}).","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')."],"exampleFix":"// before\nplugins { id 'org.apache.kafka.kafka-public-api-checker' }\n// javadocJarPath not set -> exception\n\n// after\nplugins { id 'org.apache.kafka.kafka-public-api-checker' }\n\nkafkaPublicApiChecker {\n  javadocJarPath = tasks.named('javadocJar', Jar).flatMap { it.archiveFile }\n}\ntasks.named('kafkaPublicApiCheck').configure { dependsOn('javadocJar') }","handlingStrategy":"validation","validationCode":"// Set javadocJarPath explicitly, or ensure a 'javadocJar' Jar task exists for the plugin to wire\ntasks.named<org.apache.kafka.gradle.KafkaPublicApiCheckerTask>(\"kafkaPublicApiChecker\").configure {\n    javadocJarPath.set(tasks.named<Jar>(\"javadocJar\").get().archiveFile)\n}\n// Or register the task if your project lacks it\nif (tasks.findByName(\"javadocJar\") == null) {\n    tasks.register<Jar>(\"javadocJar\") {\n        archiveClassifier.set(\"javadoc\")\n        from(tasks.named(\"javadoc\").get().outputs)\n    }\n}","typeGuard":"fun RegularFileProperty?.resolvedOrThrow(taskName: String): File =\n    this?.takeIf { it.isPresent }?.get()?.asFile\n        ?: error(\"Set kafkaPublicApiChecker.javadocJarPath or apply the plugin to a project with a '$taskName' Jar task\")","tryCatchPattern":null,"preventionTips":["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."],"tags":["gradle","kafka","api-checker","configuration","javadoc"],"analyzedSha":"c31c9215e131f8c17e79f8901b48c13ee6aa8e7a","analyzedAt":"2026-08-03T12:34:05.770Z","schemaVersion":2}