Skip to content

Commit ec0f9ec

Browse files
committed
feat(kafka-schema): rely on @Schema annotation to find schema class
1 parent 08026f8 commit ec0f9ec

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

kafka/check-local-schemas.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,19 @@ get_md5sum() {
3838
}
3939

4040
find_schema_class_file() {
41-
# The schema class heuristic is a bit hacky for now, we just expect
42-
# the filename containing the schema code to end with Schema or is named InputModel
41+
# The schema class heuristic is a bit hacky for now, we try to find a file
42+
# where a class has been annotated with the schema annotation
43+
# Otherwise we fallback on finding the filename containing the schema code
44+
# to end with Schema or is named InputModel
4345
# We might want to improve this in the future
44-
find src -name "*Schema.scala" -o -name "InputModel.scala" | head -n 1 || return 0
46+
schema_class_file="$(grep -lr "^@schema" src | head -n 1 || return 0)"
47+
48+
if [[ -z "${schema_class_file}" ]]; then
49+
schema_class_file="$(find src -name "*Schema.scala" -o -name "InputModel.scala" | head -n 1 || return 0)"
50+
fi
51+
52+
echo "${schema_class_file}"
53+
4554
}
4655

4756
find_schema_class() {

0 commit comments

Comments
 (0)