#!/bin/bash # Minimum required protoc version MIN_VERSION="28.3" # Get the installed protoc version INSTALLED_VERSION=$(protoc --version | awk '{print $2}') # Function to compare versions version_lt() { [ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" != "$1" ] } # Check if protoc is installed and meets the minimum version if ! command -v protoc &> /dev/null; then echo "Error: protoc is not installed. Please install version $MIN_VERSION or later." exit 1 fi if version_lt "$INSTALLED_VERSION" "$MIN_VERSION"; then echo "Error: protoc version $INSTALLED_VERSION is too old. Please upgrade to version $MIN_VERSION or later." exit 1 fi # Generate Java files from proto files protoc --java_out=../java ./*.proto