#! /bin/sh -f # # java-dependencies
# # Lists the Java files used by a class or classes. This is # determined by running the java compiler on that class and looking # to see what class files are built. The class files are # built in a temporary directory which is later deleted. # # sources -- directory containing all of the possible sources # main -- main files to compile. Multiple files can be specified # (in quotes). Must be full pathname to file # javac -- java compiler command to use. Can just be 'javac' # # The list of all files used by
is written to standard out. debug= # For debugging # debug=1 # get the arguments if [ $# -ne 3 ]; then echo `basename $0`" takes 3 arguments, but $# were supplied" exit 1 fi sources="$1" main="$2" javac="$3" # Determine if we have GNU find. GNU find requires -noleaf on AFS filesystems. find_args="" gnu=`find --version 2>&1 | grep -c GNU` if [ $gnu ] ; then find_args="-noleaf" fi # compile the java files scratch=`mktemp -d -t build_all_list_file.XXXXXX` $javac -d $scratch -sourcepath $sources $main if [ $status ] ; then exit 1 fi # Get all of the class files built and convert their names back to # relative Java filenames. If the corresponding Java file doesn't exist, # discard the file (this happens for inner classes, two classes in a file, # and perhaps some other cases). cd $scratch files=`find . $find_args -name '*.class' | fgrep -v '$' | sed s/class/java/ | sed 's/\.\///' | sort` for file in $files; do if [ -e $sources/$file ] ; then echo $file fi done cd .. if [ $debug ]; then echo "scratch = $scratch" else # remove the temporary directory /bin/rm -rf $scratch fi