From 8ce073c728e8ebbcb72523a311917ec325cfc128 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Fri, 29 Jul 2011 09:37:46 -0700 Subject: [PATCH] Add classpath_builder to help with java CLASSPATH Signed-off-by: Colin McCabe --- classpath_builder.py | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) create mode 100755 classpath_builder.py 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 + "\"" -- 1.6.6.rc1.39.g9a42