Skip to content

Instantly share code, notes, and snippets.

@jcrobak
Created Jan 12, 2011
Embed
What would you like to do?
builds up a classpath from a pom.xml
def build_classpath(pomfile):
"""
Returns a string suitable for passing to java -cp by running mvn
to determine all the dependencies for the specified dependency.
"""
handle, fname = tempfile.mkstemp()
cmd = MVN + ["-f", pomfile, "dependency:build-classpath",
"-Dmdep.outputFile=%s" % fname]
print "Resolving classpath"
execute(cmd)
f = open(fname, 'r')
jar_list = f.readline().strip()
f.close()
os.remove(fname)
return jar_list
def execute(command, **kwargs):
print "Executing: " + " ".join(command)
p = subprocess.Popen(command, **kwargs)
p.communicate()
result = p.returncode
if result != 0:
raise Exception("process returned with non-zero-code")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment