Skip to content

Instantly share code, notes, and snippets.

@cescoffier
Created January 9, 2012 11:45
Show Gist options
  • Save cescoffier/1582615 to your computer and use it in GitHub Desktop.
Save cescoffier/1582615 to your computer and use it in GitHub Desktop.

Revisions

  1. cescoffier revised this gist Jan 9, 2012. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion cleanup_maven_repository.sh
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,14 @@ AGE=181 # more or less 6 months and it's a palindromic prime number, so it's coo
    echo "==== To be Deleted Jars ====" >> ${OLDFILES}
    find "${M2_REPO}" -name '*-SNAPSHOT*jar' -atime +${AGE} -exec dirname {} \; >> ${OLDFILES}

    echo "==== To be Deleted Wars ====" >> ${OLDFILES}
    echo "==== To be Deleted Wars/Ears ====" >> ${OLDFILES}
    find "${M2_REPO}" -name '*-SNAPSHOT*war' -atime +${AGE} -exec dirname {} \; >> ${OLDFILES}
    find "${M2_REPO}" -name '*-SNAPSHOT*ear' -atime +${AGE} -exec dirname {} \; >> ${OLDFILES}

    echo "==== To be Deleted APKs ====" >> ${OLDFILES}
    find "${M2_REPO}" -name '*-SNAPSHOT*apk' -atime +${AGE} -exec dirname {} \; >> ${OLDFILES}
    find "${M2_REPO}" -name '*-SNAPSHOT*apksources' -atime +${AGE} -exec dirname {} \; >> ${OLDFILES}
    find "${M2_REPO}" -name '*-SNAPSHOT*apklib' -atime +${AGE} -exec dirname {} \; >> ${OLDFILES}

    for x in `cat ${OLDFILES}`; do rm -rf "$x"; done

  2. cescoffier created this gist Jan 9, 2012.
    17 changes: 17 additions & 0 deletions cleanup_maven_repository.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/bin/sh

    M2_REPO=${HOME}/.m2
    OLDFILES=/tmp/deleted_artifacts.txt
    AGE=181 # more or less 6 months and it's a palindromic prime number, so it's cool

    echo "==== To be Deleted Jars ====" >> ${OLDFILES}
    find "${M2_REPO}" -name '*-SNAPSHOT*jar' -atime +${AGE} -exec dirname {} \; >> ${OLDFILES}

    echo "==== To be Deleted Wars ====" >> ${OLDFILES}
    find "${M2_REPO}" -name '*-SNAPSHOT*war' -atime +${AGE} -exec dirname {} \; >> ${OLDFILES}

    for x in `cat ${OLDFILES}`; do rm -rf "$x"; done

    # Just as final cleanup.
    echo "==== Empty Directories ====" >> ${OLDFILES}
    find "${M2_REPO}" -type d -empty -exec rmdir {} \; >> ${OLDFILES}