Skip to content

Instantly share code, notes, and snippets.

@masih
Forked from cescoffier/cleanup_maven_repository.sh
Last active December 28, 2015 23:29
Show Gist options
  • Save masih/7579544 to your computer and use it in GitHub Desktop.
Save masih/7579544 to your computer and use it in GitHub Desktop.
#!/bin/sh
M2_REPO=${HOME}/.m2
OLDFILES=/tmp/deleted_artifacts.txt
AGE=195
echo "==== To be Deleted Jars ====" >> ${OLDFILES}
find "${M2_REPO}" -path '*SNAPSHOT*' -name '*jar' -type f -atime +${AGE} >> ${OLDFILES}
echo "==== To be Deleted Wars/Ears ====" >> ${OLDFILES}
find "${M2_REPO}" -path '*SNAPSHOT*' -name '*war' -type f -atime +${AGE} >> ${OLDFILES}
find "${M2_REPO}" -path '*SNAPSHOT*' -name '*ear' -type f -atime +${AGE} >> ${OLDFILES}
echo "==== To be Deleted APKs ====" >> ${OLDFILES}
find "${M2_REPO}" -path '*SNAPSHOT*' -name '*apk' -type f -atime +${AGE} >> ${OLDFILES}
find "${M2_REPO}" -path '*SNAPSHOT*' -name '*apksources' -type f -atime +${AGE} >> ${OLDFILES}
find "${M2_REPO}" -path '*SNAPSHOT*' -name '*apklib' -type f -atime +${AGE} >> ${OLDFILES}
echo "==== Empty Directories ====" >> ${OLDFILES}
find "${M2_REPO}" -type d -empty >> ${OLDFILES}
for x in `cat ${OLDFILES}`; do rm -rf "$x"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment