Thomas Vachuska | 6b33126 | 2015-04-27 11:09:07 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | #------------------------------------------------------------------------------- |
| 3 | # Java Package Dependency viewer |
| 4 | # |
| 5 | # written by Thomas Vachuska |
| 6 | # -- Doobs -- |
| 7 | #------------------------------------------------------------------------------- |
| 8 | |
| 9 | JDVUE_ROOT=${JDVUE_ROOT:-$(dirname $0)/..} |
| 10 | cd $JDVUE_ROOT |
Brian O'Connor | 880dc20d | 2015-12-16 22:53:14 -0800 | [diff] [blame] | 11 | VER=1.5.0-SNAPSHOT |
Thomas Vachuska | 6b33126 | 2015-04-27 11:09:07 -0700 | [diff] [blame] | 12 | JAR=$PWD/target/jdvue-${VER}.jar # start with the dev jar first |
| 13 | cd - >/dev/null |
| 14 | |
| 15 | # If the dev jar is not available, use one from .m2/repository |
| 16 | [ -f ${JAR} ] || JAR=~/.m2/repository/org/onlab/tools/jdvue/${VER}/jdvue-${VER}.jar |
| 17 | |
| 18 | # Assume default project to be the base-name of the argument or of current dir |
| 19 | name=$(basename ${1:-$PWD}) |
| 20 | |
| 21 | # If the -n option is specified use the next argument as the catalog name |
| 22 | [ "$1" = "-n" -a $# -ge 2 ] && name=$2 && shift 2 |
| 23 | |
| 24 | # Use the rest of the arguments as paths to scan for sources to build catalog |
| 25 | find "${@:-.}" -type f -name \*.java \ |
| 26 | | grep -v -E '/lost+found/|/target/|archetype-resources' \ |
| 27 | | xargs grep -E "^[ \t]*import .*;.*|^[ \t]*package .*;.*" \ |
| 28 | | tr -d '\r' > $name.db |
| 29 | |
| 30 | # Now run the Java Dependency Viewer jar on the catalog |
| 31 | java -jar ${JAR} $name && rm $name.db && open $name.html |