blob: 1782b9abe57afd2984364ebe024ce373cfda5a02 [file] [log] [blame]
Thomas Vachuska6b331262015-04-27 11:09:07 -07001#!/bin/bash
2#-------------------------------------------------------------------------------
3# Java Package Dependency viewer
4#
5# written by Thomas Vachuska
6# -- Doobs --
7#-------------------------------------------------------------------------------
8
9JDVUE_ROOT=${JDVUE_ROOT:-$(dirname $0)/..}
10cd $JDVUE_ROOT
Brian O'Connor955c3162016-03-10 15:27:19 -080011VER=1.6.0-SNAPSHOT
Thomas Vachuska6b331262015-04-27 11:09:07 -070012JAR=$PWD/target/jdvue-${VER}.jar # start with the dev jar first
13cd - >/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
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