Skip to content

Instantly share code, notes, and snippets.

@gAmUssA
Created September 3, 2024 14:55
Show Gist options
  • Save gAmUssA/af6f95e73331f72a0397a7f6651ec0d1 to your computer and use it in GitHub Desktop.
Save gAmUssA/af6f95e73331f72a0397a7f6651ec0d1 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Counters for Maven and Gradle projects
maven_count=0
gradle_count=0
echo "Starting to clean projects..."
# Recursively find directories containing pom.xml and run 'mvn clean'
while IFS= read -r -d '' file; do
(cd "$(dirname "$file")" && mvn clean) || true
maven_count=$((maven_count + 1))
done < <(find . -type f -name "pom.xml" -print0)
# Recursively find directories containing build.gradle or build.gradle.kts and run './gradlew clean'
while IFS= read -r -d '' file; do
(cd "$(dirname "$file")" && ./gradlew clean) || true
gradle_count=$((gradle_count + 1))
done < <(find . -type f \( -name "build.gradle" -o -name "build.gradle.kts" \) -print0)
echo "---------------------------------"
echo "Summary:"
echo "Maven projects cleaned: $maven_count"
echo "Gradle projects cleaned: $gradle_count"
echo "---------------------------------"
if [ $((maven_count + gradle_count)) -eq 0 ]; then
echo "No Maven or Gradle projects found."
else
echo "Total projects cleaned: $((maven_count + gradle_count))"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment