浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Tech Per » Automatic MD5 File Generation for Maven Repository

Automatic MD5 File Generation for Maven Repository

If you have a local repository for your own, in-house developed, artifacts, you might also sometimes have the need to generate MD5 sum files for these, to avoid maven warnings when downloading. I know I have this need, when I put some artifact from the outside world into my local repository. The other day, I wrote a small bash-script, which recursively goes through maven repository artifacts and generates MD5 sum files for those missing. Here is the script code:


for ext in $@; do
    for jarfile in `find . -type f -name "$ext"`; do
        MD5_FILE=${jarfile}.md5
        if [ ! -f ${MD5_FILE} ]; then
            md5sum $jarfile | cut -f1 -d" " > $MD5_FILE
            echo "generated missing: $MD5_FILE"
        fi
    done
done

Say you put this into a script named gen-md5.sh, you would use it by doing ./gen-md5.sh "*.jar" "*.pom". The script depends upon the md5sum tool being installed.

posted on 2012-03-13 08:38  lexus  阅读(453)  评论(0编辑  收藏  举报