#!/bin/sh
# Gradle wrapper stub - download if not present
GRADLE_VERSION="8.5"
GRADLE_DIR="$HOME/.gradle/wrapper/dists/gradle-${GRADLE_VERSION}-bin"

if [ ! -f "gradle/wrapper/gradle-wrapper.jar" ]; then
    echo "Downloading Gradle wrapper..."
    mkdir -p gradle/wrapper
    curl -sL "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" -o /tmp/gradle.zip
    unzip -q /tmp/gradle.zip -d /tmp
    cp /tmp/gradle-${GRADLE_VERSION}/lib/gradle-wrapper-*.jar gradle/wrapper/gradle-wrapper.jar 2>/dev/null || true
    rm -rf /tmp/gradle.zip /tmp/gradle-${GRADLE_VERSION}
fi

exec java -jar gradle/wrapper/gradle-wrapper.jar "$@"
