blob: 2e60a1d769717acb7ab08009913101aff10f8e2e [file] [log] [blame]
Jonathan Hart0b6ef8f2013-11-18 12:00:20 -08001#!/usr/bin/env python
2
3import sys
4from os import path
5from xml.dom import minidom
6
7# Location of the .classpath file relative to this script
8classpath_filename = "../.classpath"
9m2_repository = "~/.m2/repository"
10
11def parse_classpath_xml(classpath_file, abs_m2_repository):
12 xmldoc = minidom.parse(classpath_file)
13 classpathentries = xmldoc.getElementsByTagName('classpathentry')
14 classpath = ""
15 for entry in classpathentries:
16 kind = entry.attributes['kind'].value
17 if kind == "output" or kind == "var":
18 cp_entry = entry.attributes['path'].value + ":"
19
20 classpath += cp_entry.replace("M2_REPO", abs_m2_repository)
21
22 print classpath[0:-1]
23
24if __name__ == "__main__":
25 abs_m2_repository = path.expanduser("~/.m2/repository")
26
27 classpath_file = path.abspath(path.join(path.dirname(path.realpath(sys.argv[0])), classpath_filename))
28
29 try:
30 with open(classpath_file) as f:
31 parse_classpath_xml(f, abs_m2_repository)
32 except IOError:
33 print "Error reading classpath file from %s" % classpath_file
34 print "- Please check path is correct then run 'mvn eclipse:eclipse' to generate file"