2021-02-05 21:03:04 -08:00
|
|
|
#!/bin/bash
|
|
|
|
set -euxo pipefail
|
|
|
|
|
2021-02-15 15:04:21 -08:00
|
|
|
OUTDIR=./src/datahub/metadata
|
2021-02-05 21:03:04 -08:00
|
|
|
|
|
|
|
# Note: this assumes that datahub has already been built with `./gradlew build`.
|
2021-02-15 11:44:29 -08:00
|
|
|
DATAHUB_ROOT=..
|
2021-06-24 17:11:00 -07:00
|
|
|
SCHEMAS_ROOT="$DATAHUB_ROOT/metadata-events/mxe-schemas/src/renamed/avro/com/linkedin"
|
2021-09-26 17:22:58 -07:00
|
|
|
FILES="$SCHEMAS_ROOT/mxe/MetadataChangeEvent.avsc $SCHEMAS_ROOT/mxe/MetadataChangeProposal.avsc $SCHEMAS_ROOT/usage/UsageAggregation.avsc"
|
|
|
|
# Since we depend on jq, check if jq is installed
|
|
|
|
if ! which jq; then
|
|
|
|
echo "jq is not installed. Please install jq and rerun (https://stedolan.github.io/jq/)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
find $SCHEMAS_ROOT -name "*.avsc" | sort | while read file
|
|
|
|
do
|
|
|
|
# Add all other files that are aspects but not included in the above
|
|
|
|
if (jq '.Aspect' -e $file > /dev/null)
|
|
|
|
then
|
|
|
|
FILES="${FILES} ${file}"
|
|
|
|
fi
|
|
|
|
echo $FILES > /tmp/codegen_files.txt
|
|
|
|
done
|
|
|
|
|
|
|
|
FILES=$(cat /tmp/codegen_files.txt)
|
2021-02-05 21:03:04 -08:00
|
|
|
|
|
|
|
rm -r $OUTDIR || true
|
2021-06-17 10:04:28 -07:00
|
|
|
python scripts/avro_codegen.py $FILES $OUTDIR
|