Common script for Mac/Linux/Windows
The files must be located in the root folders of the project:
- .run/BuildCleaner.run.xml
- scripts/buildCleaner.sh
The script is launched from Run/Debug Configurations
<component name="ProjectRunConfigurationManager"> | |
<configuration default="false" name="BuildCleaner" type="ShConfigurationType"> | |
<option name="SCRIPT_TEXT" value="" /> | |
<option name="INDEPENDENT_SCRIPT_PATH" value="true" /> | |
<option name="SCRIPT_PATH" value="$PROJECT_DIR$/scripts/buildCleaner.sh" /> | |
<option name="SCRIPT_OPTIONS" value="" /> | |
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" /> | |
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" /> | |
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" /> | |
<option name="INTERPRETER_PATH" value="/usr/bin/env" /> | |
<option name="INTERPRETER_OPTIONS" value="bash" /> | |
<option name="EXECUTE_IN_TERMINAL" value="true" /> | |
<option name="EXECUTE_SCRIPT_FILE" value="true" /> | |
<envs /> | |
<method v="2" /> | |
</configuration> | |
</component> |
#!/usr/bin/env bash | |
# Colors for outputting the result | |
GREEN='\033[0;32m' | |
RED='\033[0;31m' | |
NC='\033[0m' # no color | |
if [[ "$OSTYPE" == "darwin"* ]] || [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
build_folders=$(find . -name "build" -type d) | |
if [[ -z "$build_folders" ]]; then | |
echo -e "${RED}No build folders found.${NC}" | |
else | |
find . -name "build" -type d -print -exec rm -rf {} + | |
echo -e "${GREEN}All build folders have been successfully removed!${NC}" | |
fi | |
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then | |
folders=$(powershell.exe -Command "Get-ChildItem -Path . -Recurse -Directory -Filter 'build' | ForEach-Object { \$_.FullName }") | |
if [[ -z "$folders" ]]; then | |
echo -e "${RED}No build folders found.${NC}" | |
else | |
echo "Removed build folders:" | |
echo "$folders" | |
powershell.exe -Command "Get-ChildItem -Path . -Recurse -Directory -Filter 'build' | ForEach-Object { Remove-Item -Recurse -Force \$_.FullName }" | |
echo -e "${GREEN}All build folders have been successfully removed!${NC}" | |
fi | |
else | |
echo -e "${RED}Unsupported OS type: $OSTYPE${NC}" | |
fi |