blob: db3ec5c90c177b96d9678b0042e9c44779d6b570 [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
30# Now run the Java Dependency Viewer jar on the catalog
31java -jar ${JAR} $name && rm $name.db && open $name.html