# remove all existing jars (and/or links) from existing project's lib directories
ls -R */lib/*.jar

# get list of all jars into alljars
ls $1 > alljars

# make a file full of grep directives (this locates all projects needing each jar)
awk -F/ '{print "grep -Rl", $1, "* --include .classpath"}' < alljars > tempgrep

# so sad... this string gets injected below -- someone help me
thing="| awk -F/ \\\"{print \\\\\\\"ln -s\\\\\\\", \\\\\\\"$1/\\\\\\\" thejar, \\\\\\\"./\\\\\\\" \\\\\$1 \\\\\\\"/lib/\\\\\\\" thejar }\\\" thejar="

rm tempsymlinkjars1.sh
rm tempsymlinkjars2.sh

# make a script that will run each grep in tempgrep and build a file full of awk commands, each of which will in turn build all the link commands
awk "{print \$0, \"$thing\" \$3}" tempgrep > tempsymlinkjars1.sh

sh tempsymlinkjars1.sh > tempsymlinkjars2.sh

sh tempsymlinkjars2.sh 


