Last active
July 11, 2023 18:33
-
-
Save turing85/994c74f0e976f8f6178032ce36e8f808 to your computer and use it in GitHub Desktop.
clean all maven projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "finding all poms" | |
readarray -t poms < <(find "${1:-${MVN_CLEAN_ROOT}}" -name "pom.xml" || true) | |
echo "found ${#poms[@]} poms." | |
echo "deduping poms" | |
projects_to_clean=() | |
for pom in "${poms[@]}" | |
do | |
project_path=$"${pom/\/pom.xml/}" | |
already_covered='false' | |
for index in "${!projects_to_clean[@]}" | |
do | |
project_to_clean="${projects_to_clean[${index}]}" | |
if [[ "${project_path}" =~ ${project_to_clean}.* ]] | |
then | |
already_covered='true' | |
# echo "${project_path} is already covered, skipping." | |
break | |
elif [[ "${project_to_clean}" =~ ${project_path}.* ]] | |
then | |
# echo "${project_path} superceeds ${project_to_clean}, removing ${project_to_clean}" | |
unset 'projects_to_clean[${index}]' | |
fi | |
done | |
if [[ "${already_covered}" == 'false' ]] | |
then | |
projects_to_clean+=( "${project_path}" ) | |
# echo "${project_path} is new, adding." | |
fi | |
done | |
echo "${#projects_to_clean[@]} projects to clean. Starting." | |
printf "%s\n" "${projects_to_clean[@]}" | xargs -I {} -n1 -P4 mvn --file={}/pom.xml clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment