Thomas Vachuska | 6b33126 | 2015-04-27 11:09:07 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | #------------------------------------------------------------------------------- |
| 3 | # Java Package Dependency viewer |
Thomas Vachuska | 6b33126 | 2015-04-27 11:09:07 -0700 | [diff] [blame] | 4 | #------------------------------------------------------------------------------- |
| 5 | |
Thomas Vachuska | c356210 | 2016-06-16 03:02:22 -0700 | [diff] [blame] | 6 | VER=${JDVUE_VERSION:-2.0} |
| 7 | JAR=~/.m2/repository/org/onosproject/jdvue/$VER/jdvue-$VER.jar |
Thomas Vachuska | 6b33126 | 2015-04-27 11:09:07 -0700 | [diff] [blame] | 8 | |
Thomas Vachuska | c356210 | 2016-06-16 03:02:22 -0700 | [diff] [blame] | 9 | # Download the jdvue binary if needed |
| 10 | if [ ! -f $JAR ]; then |
| 11 | printf "Downloading jdvue binary..." |
| 12 | aux=/tmp/stc-$$.log |
| 13 | mvn dependency:get -Dartifact=org.onosproject:jdvue:$VER -Dtransitive=false -B >$aux || fgrep '[ERROR]' $aux |
| 14 | rm -f $aux |
| 15 | [ -f $JAR ] && printf "Done.\n" |
| 16 | fi |
Thomas Vachuska | 6b33126 | 2015-04-27 11:09:07 -0700 | [diff] [blame] | 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 | |
Thomas Vachuska | e006e7d | 2017-06-23 09:39:47 -0700 | [diff] [blame^] | 30 | DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=y" |
| 31 | |
Thomas Vachuska | 6b33126 | 2015-04-27 11:09:07 -0700 | [diff] [blame] | 32 | # Now run the Java Dependency Viewer jar on the catalog |
Thomas Vachuska | e006e7d | 2017-06-23 09:39:47 -0700 | [diff] [blame^] | 33 | [ -z "$jdvueDebug" ] && DEBUG_OPTS="" |
| 34 | java $DEBUG_OPTS -jar ${JAR} $name && rm $name.db && open $name.html |