Skip to content

Instantly share code, notes, and snippets.

@nikartx
Last active July 16, 2024 21:56
Show Gist options
  • Save nikartx/727bd466b207eb61acaddb1283ed76aa to your computer and use it in GitHub Desktop.
Save nikartx/727bd466b207eb61acaddb1283ed76aa to your computer and use it in GitHub Desktop.
Remove all 'build' dirs from all modules in android project. Better and faster then Clean Project.

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
if [[ "$OSTYPE" == "darwin"* ]] || [[ "$OSTYPE" == "linux-gnu"* ]]; then
find . -name "build" -type d -print -exec rm -rf {} +
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 "Removed build folders:"
echo "$folders"
powershell.exe -Command "Get-ChildItem -Path . -Recurse -Directory -Filter 'build' | ForEach-Object { Remove-Item -Recurse -Force \$_.FullName }"
else
echo "No build folders found."
fi
else
echo "Unsupported OS type: $OSTYPE"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment