(no subject)

Oct 30, 2013 17:47

Ок, с использованием JDepend вышла небольшая лажа, поэтому прийдется использовать технологии 60-х годов прошлого века

#!/bin/sh

checkImport() {
# 1 - java file
filename=${1}
# 2 - imported class
classfile=${2}
importedClass=$(echo $classfile | sed "s/.*\.\([^.]*\)$/\1/")
count=$(egrep "(^|[^A-Za-z0-9])$importedClass([^A-Za-z0-9]|$)" $filename | grep -v "^import" | wc -l)
if [ $count == 0 ] ; then
echo -e "$importedClass "
fi
return $count
}

checkFile() {
# 1 - java file
filename=${1}

grep "^import .*\;\s*$" $filename | sed "s/import //;s/\;.*//" |
while read classfile
do
checkImport $filename $classfile
done
return 0
}

find ./ -name "*.java" |
while read filename
do
output=$(checkFile $filename)
if [ "X$output" != "X" ] ; then
echo "In $filename"
echo "Unsed imports: "$output
fi
done

java, dependencies, shell

Previous post Next post
Up