#!/bin/bash is_reposilite_up () { nc repo 80 > /dev/null return $? } wait_for_reposilite () { i=0 until is_reposilite_up; do i=$((i+1)) if [ $i -gt 30 ]; then return $i fi sleep 1 done return $i } # Main scipt echo "Check that reposilite is running" wait_for_reposilite if [[ ! -f /package-list.yaml ]]; then echo "No /package-list.yaml file. Aborting" exit 255 fi export PROJECTS_DIR=/gradle-projects mkdir -p "${PROJECTS_DIR}" export GRADLE_VERSIONS_DIR=/gradle-versions mkdir -p "${GRADLE_VERSIONS_DIR}" echo "Resolving packages and generating gradle config" python3 --version if ! python3 src/main.py --repo="repo:80" --output-dir "$PROJECTS_DIR" /package-list.yaml; then echo "Gradle generation failed" exit 255 fi if [ $? -lt 30 ]; then for path in "$PROJECTS_DIR"/*; do version=$(basename "${path}") gradle_path=${GRADLE_VERSIONS_DIR}/gradle-${version} if [[ "${version}" == "${GRADLE_VERSION}" ]] || [[ "${version}" == "default" ]]; then gradle_path=${GRADLE_HOME} elif [[ ! -d "${gradle_path}" ]]; then echo "Downloading gradle ${version}" filename="gradle-${version}-bin.zip" wget "https://services.gradle.org/distributions/${filename}" unzip -q "${filename}" -d "${GRADLE_VERSIONS_DIR}" rm "${filename}" if [[ ! -d "${gradle_path}" ]]; then echo "ERROR: Could not fetch gradle ${version}" continue fi fi for project in "${path}"/*; do echo "-----------------------Config for $project-------------------------------" echo "Running $project" cat "$project/build.gradle.kts" echo "-----------------------Running gradle------------------------------------" (cd "$project" && "${gradle_path}/bin/gradle" --info -Dorg.gradle.jvmargs=-Xms4096m downloadDependencies) done done else echo "Can't connect to repository" exit 255 fi