blob: 9a5ec455ea8d473728cb802e6f0ce372d56f2571 [file] [log] [blame]
Thomas Vachuska6b331262015-04-27 11:09:07 -07001#!/bin/bash
2#-------------------------------------------------------------------------------
3# Java Package Dependency viewer
Thomas Vachuska6b331262015-04-27 11:09:07 -07004#-------------------------------------------------------------------------------
5
Thomas Vachuskac3562102016-06-16 03:02:22 -07006VER=${JDVUE_VERSION:-2.0}
7JAR=~/.m2/repository/org/onosproject/jdvue/$VER/jdvue-$VER.jar
Thomas Vachuska6b331262015-04-27 11:09:07 -07008
Thomas Vachuskac3562102016-06-16 03:02:22 -07009# Download the jdvue binary if needed
10if [ ! -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"
16fi
Thomas Vachuska6b331262015-04-27 11:09:07 -070017
18# Assume default project to be the base-name of the argument or of current dir
19name=$(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
25find "${@:-.}" -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 Vachuskae006e7d2017-06-23 09:39:47 -070030DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=y"
31
Thomas Vachuska6b331262015-04-27 11:09:07 -070032# Now run the Java Dependency Viewer jar on the catalog
Thomas Vachuskae006e7d2017-06-23 09:39:47 -070033[ -z "$jdvueDebug" ] && DEBUG_OPTS=""
34java $DEBUG_OPTS -jar ${JAR} $name && rm $name.db && open $name.html