查找maven工程中循环依赖的脚本
目录
[显示]
1.摘要
本来以为会很复杂,结果发现maven本身已经自带了循环依赖的检测,只是要把依赖链输出就可以了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#!/bin/bash ### find cycle in maven depnedency tree if [ $# -gt 0 ];then sourcepath=$1 else sourcepath=`pwd` fi if [ ! -f "$sourcepath/pom.xml" ]; then echo "$sourcepath is not a vaild maven project!" echo 'Usage : ./findcycle [path]' exit 1; fi mvn=`which mvn` if [ "$mvn" = "" ];then echo "counld not found mvn in PATH,exit!" exit 1; fi cd $sourcepath echo "scan cycle dependency in $sourcepath ..." mvn dependency:tree -Dverbose | awk -F'- ' '{if(index($2,"maven-dependency-plugin")>0){indent=0;}else{indent=length($1);}stack[indent]=$2;if(index($0,"for cycle")>0){print "****found cycle****";for(i=0;i<=indent;i++){if(stack[i]!=null){print "->"stack[i]}}}}' echo "scan finished!" |
本作品采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可,转载请注明作者及原网址。
抱歉,暂停评论。