You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "regarmukesh3g (via GitHub)" <gi...@apache.org> on 2026/09/05 19:47:24 UTC
[PR] KAFKA-21011: Declare server as an api dependency of core [kafka]
regarmukesh3g opened a new pull request, #23373:
URL: https://github.com/apache/kafka/pull/23373
[KAFKA-21011](https://issues.apache.org/jira/browse/KAFKA-21011)
## Problem
The published pom for `org.apache.kafka:kafka_2.13` lists `org.apache.kafka:kafka-server` with `runtime` scope:
```xml
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-server</artifactId>
<version>4.1.3</version>
<scope>runtime</scope>
</dependency>
```
This is because `core` declares it as an `implementation` dependency in `build.gradle`.
However, `kafka.server.KafkaConfig` extends `org.apache.kafka.server.config.AbstractKafkaConfig`, which lives in the `server` module:
```scala
class KafkaConfig private(doLog: Boolean, val props: util.Map[_, _], enforceProviderAllowlist: Boolean)
extends AbstractKafkaConfig(
```
That supertype is therefore part of `core`'s compile-time API surface. With `kafka-server` only on the runtime classpath, a consumer that references `KafkaConfig` cannot see its supertype when compiling. The Kotlin compiler already warns about this and is moving towards rejecting it outright:
```
w: Cannot access 'org.apache.kafka.server.config.AbstractKafkaConfig' which is a supertype
of 'KafkaConfig'. This may be forbidden soon. Check the module classpath for missing or
conflicting dependencies.
```
Users currently have to work around it by re-declaring `kafka-server` themselves, which dependency-analysis linters then flag as an unnecessary explicit dependency.
## Fix
Declare `server` as an `api` dependency of `core`, which puts `kafka-server` in `compile` scope in the generated pom.
This matches the existing treatment of `clients`. The comment already sitting above that declaration records the rationale:
```gradle
// `core` is often used in users' tests, define the following dependencies as `api` for backwards compatibility
// even though the `core` module doesn't expose any public API
api project(':clients')
```
## Testing
This is a build-configuration change, so it is verified against the generated pom rather than a unit test. There is no existing test asserting pom contents.
**Generated pom before** (`./gradlew :core:generatePomFileForMavenJavaPublication`):
```
kafka-clients compile
kafka-server runtime
```
**After:**
```
kafka-clients compile
kafka-server compile
```
A structured comparison of the full pom confirms `kafka-server`'s scope is the only dependency change — no dependencies added or removed (25 before, 25 after).
**The resolved `runtimeClasspath` of `core` is byte-identical before and after** (32 entries, `diff` clean), so this changes only the scope recorded in the published pom, not what actually ends up on the classpath.
`:core:compileScala`, `:core:compileTestScala`, `:core:jar`, and the dependent modules `:tools`, `:streams` and `:connect:runtime` all compile cleanly.
### A note on the dropped exclusions
Moving the dependency from `implementation` to `api` means `kafka-server` no longer carries the `javax`/`jline`/`jms`/`jmxri`/`jmxtools`/`mail` exclusions in the pom, since those are attached to the `implementation` configuration:
```gradle
configurations {
// manually excludes some unnecessary dependencies
implementation.exclude module: 'javax'
...
}
```
This is consistent with the existing `api` dependencies — `kafka-clients` and `scala-library` never carried those exclusions either. The exclusions guard against transitive dependencies of old log4j 1.x artifacts, and none of the excluded modules appear anywhere in `core`'s resolved dependency graph. This is corroborated by the unchanged `runtimeClasspath` above.
I'm happy to instead promote the exclusions to a configuration that covers `api` as well, if reviewers would prefer to keep them attached defensively.
### Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01GvbzZgK7eH63iPswf8tV6v
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-21011: Declare server as an api dependency of core [kafka]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #23373:
URL: https://github.com/apache/kafka/pull/23373#issuecomment-5738950590
A label of 'needs-attention' was automatically added to this PR in order to raise the
attention of the committers. Once this issue has been triaged, the `triage` label
should be removed to prevent this automation from happening again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-21011: Declare server as an api dependency of core [kafka]
Posted by "regarmukesh3g (via GitHub)" <gi...@apache.org>.
regarmukesh3g commented on PR #23373:
URL: https://github.com/apache/kafka/pull/23373#issuecomment-5574274653
@chia7712 would you be willing to take a look when you have a moment? You commented on [KAFKA-21011](https://issues.apache.org/jira/browse/KAFKA-21011) about the ongoing modularization of `core`, so this touches directly on that work.
@mimaison @m1a2st you have both reviewed recent `build.gradle` dependency changes, so your input would be welcome too.
One point I would especially like a second opinion on: moving `:server` from `implementation` to `api` means it no longer inherits the `javax`/`jline`/`jms`/`jmxri`/`jmxtools`/`mail` exclusions, since those are attached to the `implementation` configuration. This is consistent with the existing `api` dependencies (`kafka-clients` and `scala-library` never carried them), the exclusions guard against old log4j 1.x transitives, and `core`'s resolved `runtimeClasspath` is byte-identical before and after. But if you would rather keep them attached defensively, I am happy to promote the exclusions to a configuration that also covers `api`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org