forked from oldratlee/useful-scripts
-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathfindcycle
More file actions
executable file
·23 lines (21 loc) · 712 Bytes
/
Copy pathfindcycle
File metadata and controls
executable file
·23 lines (21 loc) · 712 Bytes
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!"