-
-
Save omidp/4a26d84d0cae8ba29571ea74a4fcf4e0 to your computer and use it in GitHub Desktop.
Small shell-script to visualize import dependencies between Java classes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cat >dependencies.dot <<EOF | |
digraph g { | |
graph [ | |
rankdir = "LR" | |
]; | |
node [ | |
fontsize = "12" | |
fontname = "Courier" | |
shape = "ellipse" | |
]; | |
EOF | |
PACKAGE=`pwd | sed "s/.*src\/main\/java\/\(.*\)/\1/" | sed "s/\//./g"` | |
for i in `ls | grep -v \.java` | |
do | |
grep -roh "import $PACKAGE.[a-z][^.]*" $i | sort| uniq | grep -v static | sed "s/import $PACKAGE.\([a-z][^.]*\).*/\1/" | grep -v $i | sed "s/\(.*\)/\"$i\" -> \"\1\"/"; | |
if grep -roh "import $PACKAGE.[A-Z][^.]*" $i >/dev/null | |
then | |
echo "\"$i\" -> \"<root>\"" >>dependencies.dot | |
fi | |
done >>dependencies.dot | |
grep -oh "import $PACKAGE.[a-z][^.]*" *java 2>/dev/null| sort| uniq | grep -v static | sed "s/import $PACKAGE.\([a-z][^.]*\).*/\1/" | sed "s/\(.*\)/\"<root>\" -> \"\1\"/" >>dependencies.dot; | |
cat >>dependencies.dot <<EOF | |
} | |
EOF | |
dot -Tpng -o dependencies.png dependencies.dot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment