Skip to content

Commit

Permalink
upgrade version of Kafka embedded server to 3.2.7 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
whummer authored Apr 2, 2024
1 parent 66b1ebf commit 4e1e6d5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions kafka-server/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
kafka-server.iml
local.properties
kafka-embedded-env/
17 changes: 16 additions & 1 deletion kafka-server/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
KAFKA_EMBEDDED_ENV_VERSION ?= 3.2.7
KAFKA_EMBEDDED_ENV_COMMIT ?= a5a21c8c6593d30860160cff54ffd350f7e1a0d5

usage: ## Show this help
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

patch: ## Clone and patch the kafka-embedded-env repo, build code into local Maven repo
test -e kafka-embedded-env || git clone https://github.com/navikt/kafka-embedded-env
(cd kafka-embedded-env; git checkout $(KAFKA_EMBEDDED_ENV_COMMIT))
# note: using perl instead of sed below, for better Linux/MacOS cross-compatibility
perl -i -pe 's|<jvmTarget>17<|<jvmTarget>11<|g' kafka-embedded-env/pom.xml
perl -i -pe 's|<maven\.compiler\.source>17<|<maven.compiler.source>11<|g' kafka-embedded-env/pom.xml
perl -i -pe 's|<maven\.compiler\.target>17<|<maven.compiler.target>11<|g' kafka-embedded-env/pom.xml
(cd kafka-embedded-env; mvn -B versions:set -DnewVersion="$(KAFKA_EMBEDDED_ENV_VERSION)" -DgenerateBackupPoms=false)
(cd kafka-embedded-env; mvn install)

build: ## Build the JAR file
gradle shadowJar

.PHONY: build
clean: ## Clean up local temporary files
rm -rf kafka-embedded-env

.PHONY: usage build patch clean
15 changes: 15 additions & 0 deletions kafka-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,24 @@

## Building

Note: recent versions of [`kafka-embedded-env`](https://github.com/navikt/kafka-embedded-env) require Java 17+, whereas we only have JRE 11 installed in the LocalStack container.
Hence, we first need to check out and patch the repo locally:
```
make patch
```

To build the latest version of the embedded server, run this command:
```
make build
```

On successful build, this will generate a file `build/libs/kafka-server-all.jar` which should then be renamed to `kafka-server-all-<version>.jar` (e.g., `kafka-server-all-3.1.0.jar`) and pushed to the `localstack-assets` S3 bucket.

## Upgrading

To upgrade to a newer version, follow these steps:

* Adjust `KAFKA_EMBEDDED_ENV_VERSION` and `KAFKA_EMBEDDED_ENV_COMMIT` in `Makefile`
* Adjust the version in `implementation("no.nav:kafka-embedded-env:<version>")` in `build.gradle`
* Run `make clean` to ensure that local patches are cleaned up
* Run `make patch` and `make build` as per instructions further above
4 changes: 2 additions & 2 deletions kafka-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
}

repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://packages.confluent.io/maven'
Expand All @@ -16,8 +17,7 @@ repositories {
}

dependencies {
// note: later versions of kafka-embedded-env require Java 17+, whereas we only have JRE 11 installed in the LS container
implementation("no.nav:kafka-embedded-env:3.1.0") {
implementation("no.nav:kafka-embedded-env:3.2.7") {
exclude group: 'log4j', module: 'log4j'
// exclude libs to prevent CVEs with certain versions
exclude group: 'io.confluent', module: 'confluent-log4j'
Expand Down

0 comments on commit 4e1e6d5

Please sign in to comment.