You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`storage` — Storage abstraction layer; `storage:storage-api` defines the interface.
41
+
-`metadata` / `raft` — KRaft metadata and consensus.
42
+
-`group-coordinator` / `transaction-coordinator` — Coordinator logic extracted from core.
43
+
-`tools` — CLI tools (shell scripts in `bin/` delegate to Java classes here).
44
+
-`automq-shell` — AutoMQ-specific CLI commands.
45
+
46
+
## AutoMQ Inject Pattern
47
+
48
+
AutoMQ customizations inside upstream Kafka files are wrapped with marker comments:
49
+
50
+
```java
51
+
// AutoMQ inject start
52
+
// ... AutoMQ-specific code ...
53
+
// AutoMQ inject end
54
+
```
55
+
56
+
When adding new AutoMQ functionality to an existing Kafka class, always use these markers. This makes it easy to track divergence from upstream and resolve merge conflicts.
57
+
58
+
To find all injection points: `grep -rn "AutoMQ inject" --include="*.java"`.
59
+
60
+
## Code Generation
61
+
62
+
Several modules generate Java source from JSON message definitions:
-**Task**: `processMessages` (runs automatically before `compileJava`)
67
+
68
+
Do not edit files under `src/generated/` — they are overwritten on each build.
69
+
70
+
## Adding a New AdminClient Method
71
+
72
+
The pattern used throughout the codebase:
73
+
74
+
1. Add `default` + abstract method pair to `Admin.java` inside the `// AutoMQ inject` block.
75
+
2. Add a stub `@Override` to `ForwardingAdmin.java` and `MockAdminClient.java` (test) inside their inject blocks — the build will fail with a compile error if you miss these.
76
+
3. Create `*Options` (extends `AbstractOptions<T>`) and `*Result` (wraps `KafkaFuture`) classes in `clients/src/main/java/org/apache/kafka/clients/admin/`.
77
+
4. Implement in `KafkaAdminClient.java` inside the inject block. For RPC-based methods use the `Call` pattern; for client-side reads (like `describeClusterEvents`) use a dedicated helper class.
78
+
79
+
## Dependency Management
80
+
81
+
Dependencies are declared in `gradle/dependencies.gradle` (not `build.gradle`):
82
+
83
+
```groovy
84
+
// In versions map:
85
+
myLib: "1.0.0"
86
+
87
+
// In libs map:
88
+
myLib: "com.example:my-lib:$versions.myLib"
89
+
```
90
+
91
+
Then referenced in `build.gradle` as `implementation libs.myLib`. The `clients` module uses a shadow jar — dependencies added there are shaded; `com.google.protobuf` is relocated to `org.apache.kafka.shaded.com.google.protobuf`, so avoid passing protobuf `Message` objects across the clients module boundary.
92
+
93
+
## Checkstyle & Spotless
94
+
95
+
Checkstyle enforces:
96
+
- Max cyclomatic complexity: 16
97
+
- Max NPath complexity: 500
98
+
- No `toLowerCase()`/`toUpperCase()` without a `Locale` argument
99
+
- Import ordering (run `spotlessApply` to fix automatically)
100
+
101
+
When adding new files, run `./gradlew :module:spotlessApply` before building to avoid import-order failures.
102
+
103
+
## Integration Testing
104
+
105
+
If your change or new feature requires integration testing, you can launch a local cluster by following the commands in `devkit/README.md`.
Copy file name to clipboardExpand all lines: build.gradle
+38-3Lines changed: 38 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,7 @@ plugins {
44
44
// Updating the shadow plugin version to 8.1.1 causes issue with signing and publishing the shadowed
45
45
// artifacts - see https://github.com/johnrengelman/shadow/issues/901
46
46
id 'com.github.johnrengelman.shadow' version '8.1.0' apply false
47
+
id 'com.google.protobuf' version '0.9.4' apply false
47
48
// Spotless 6.13.0 has issue with Java 21 (see https://github.com/diffplug/spotless/pull/1920), and Spotless 6.14.0+ requires JRE 11
48
49
// We are going to drop JDK8 support. Hence, the spotless is upgrade to newest version and be applied only if the build env is compatible with JDK 11.
49
50
// spotless 6.15.0+ has issue in runtime with JDK8 even through we define it with `apply:false`. see https://github.com/diffplug/spotless/issues/2156 for more details
0 commit comments