From: Colin Patrick McCabe Date: Fri, 29 Jul 2011 16:37:46 +0000 (-0700) Subject: Add classpath_builder to help with java CLASSPATH X-Git-Url: http://club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ce073c728e8ebbcb72523a311917ec325cfc128;p=cmccabe-bin Add classpath_builder to help with java CLASSPATH Signed-off-by: Colin McCabe --- diff --git a/classpath_builder.py b/classpath_builder.py new file mode 100755 index 0000000..174a35b --- /dev/null +++ b/classpath_builder.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +import os +import subprocess +import sys + +def usage(): + print >>sys.stderr, "classpath_builder takes a directory, and returns \ +the CLASSPATH environment variable that would give you access to all the \ +jars in or under that directory.\n" + print >>sys.stderr, "Usage: classpath_builder.py [directory-name]" + +if (len(sys.argv) == 1): + usage() + sys.exit(1) +if (sys.argv[1] == "-h") or (sys.argv[1] == "--help"): + usage() + sys.exit(0) +if (not os.path.exists(sys.argv[1])): + usage() + sys.exit(1) +proc = subprocess.Popen(["find", sys.argv[1], "-name", "*.jar"], \ + shell=False, stdout=subprocess.PIPE) +data = proc.communicate()[0] +lines = data.splitlines() +sep="" +outs=":".join(lines) +print "CLASSPATH=\"$CLASSPATH:" + outs + "\""