Skip to content

Instantly share code, notes, and snippets.

@herisulistiyanto
Created August 21, 2023 06:33
Show Gist options
  • Save herisulistiyanto/7e2108f5a56d9776eb6eb22794565a00 to your computer and use it in GitHub Desktop.
Save herisulistiyanto/7e2108f5a56d9776eb6eb22794565a00 to your computer and use it in GitHub Desktop.
gradle-cleaner.sh
#!/usr/bin/env bash
clear
function prompt_and_clear() {
local folder_path=$1
local folder_name=$2
if [ -d "$folder_path" ]; then
local folder_size=$(du -sh $folder_path | cut -f1)
echo "Size of $folder_name: $folder_size"
read -p "Do you want to remove $folder_name? (Y/y or N/n): " confirmation
if [ "$confirmation" == "Y" ] || [ "$confirmation" == "y" ]; then
rm -rf $folder_path
echo "$folder_name has been cleared."
else
echo "$folder_name was not cleared."
fi
else
echo "$folder_name does not exist."
fi
}
# Prompt to clear Gradle cache
prompt_and_clear "$HOME/.gradle/caches/" "Gradle cache"
# Prompt to clear daemon log files
prompt_and_clear "$HOME/.gradle/daemon/" "Gradle daemon"
# Prompt to clear dist folder inside wrapper directory
prompt_and_clear "$HOME/.gradle/wrapper/dists/" "Gradle dist folder"
echo "Process completed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment