blob: 91650d5c3648bc53cd011e3562450796d1315415 [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 Vachuska812c0922017-07-06 14:55:37 -07006VER=${JDVUE_VERSION:-2.2}
Thomas Vachuskac3562102016-06-16 03:02:22 -07007JAR=~/.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
Thomas Vachuska6b331262015-04-27 11:09:07 -070018# If the -n option is specified use the next argument as the catalog name
19[ "$1" = "-n" -a $# -ge 2 ] && name=$2 && shift 2
20
Thomas Vachuska812c0922017-07-06 14:55:37 -070021# If the -t option is specified, use only test sources; -a use all sources
22# If the -m option is specified, use only main sources; default.
23[ "$1" = "-m" ] && srcPattern="/src/main/java/" && shift 1
24[ "$1" = "-t" ] && srcPattern="/src/test/java/" && shift 1
25[ "$1" = "-a" ] && srcPattern="/src/(main|test)/java/" && shift 1
26
27# Assume default project to be the base-name of the argument or of current dir
28name=$(basename ${1:-$PWD})
29
Thomas Vachuska6b331262015-04-27 11:09:07 -070030# Use the rest of the arguments as paths to scan for sources to build catalog
31find "${@:-.}" -type f -name \*.java \
Thomas Vachuska812c0922017-07-06 14:55:37 -070032 | grep -E "${srcPattern:-/src/main/java}" \
Thomas Vachuska6b331262015-04-27 11:09:07 -070033 | grep -v -E '/lost+found/|/target/|archetype-resources' \
34 | xargs grep -E "^[ \t]*import .*;.*|^[ \t]*package .*;.*" \
35 | tr -d '\r' > $name.db
36
Thomas Vachuskae006e7d2017-06-23 09:39:47 -070037DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=y"
38
Thomas Vachuska6b331262015-04-27 11:09:07 -070039# Now run the Java Dependency Viewer jar on the catalog
Thomas Vachuskae006e7d2017-06-23 09:39:47 -070040[ -z "$jdvueDebug" ] && DEBUG_OPTS=""
41java $DEBUG_OPTS -jar ${JAR} $name && rm $name.db && open $name.html