comparison mxtool/mx.py @ 16417:9fe3cb463079

mx: classpath function now accepts distributions as well (which are prepend to the class path)
author Doug Simon <doug.simon@oracle.com>
date Mon, 07 Jul 2014 14:51:53 +0200
parents f5437f2db322
children 59fdea1f9e36
comparison
equal deleted inserted replaced
16416:4fe215bc2da5 16417:9fe3cb463079
1201 cp += [_opts.cp_suffix] 1201 cp += [_opts.cp_suffix]
1202 return os.pathsep.join(cp) 1202 return os.pathsep.join(cp)
1203 1203
1204 def classpath(names=None, resolve=True, includeSelf=True, includeBootClasspath=False): 1204 def classpath(names=None, resolve=True, includeSelf=True, includeBootClasspath=False):
1205 """ 1205 """
1206 Get the class path for a list of given dependencies, resolving each entry in the 1206 Get the class path for a list of given dependencies and distributions, resolving each entry in the
1207 path (e.g. downloading a missing library) if 'resolve' is true. 1207 path (e.g. downloading a missing library) if 'resolve' is true.
1208 """ 1208 """
1209 if names is None: 1209 if names is None:
1210 result = _as_classpath(sorted_deps(includeLibs=True), resolve) 1210 deps = sorted_deps(includeLibs=True)
1211 dists = list(_dists.values())
1211 else: 1212 else:
1212 deps = [] 1213 deps = []
1214 dists = []
1213 if isinstance(names, types.StringTypes): 1215 if isinstance(names, types.StringTypes):
1214 names = [names] 1216 names = [names]
1215 for n in names: 1217 for n in names:
1216 dependency(n).all_deps(deps, True, includeSelf) 1218 dep = dependency(n, fatalIfMissing=False)
1217 result = _as_classpath(deps, resolve) 1219 if dep:
1220 dep.all_deps(deps, True, includeSelf)
1221 else:
1222 dist = distribution(n)
1223 if not dist:
1224 abort('project, library or distribution named ' + n + ' not found')
1225 dists.append(dist)
1226
1227 if len(dists):
1228 distsDeps = set()
1229 for d in dists:
1230 distsDeps.update(d.sorted_deps())
1231
1232 # remove deps covered by a dist that will be on the class path
1233 deps = [d for d in deps if d not in distsDeps]
1234
1235 result = _as_classpath(deps, resolve)
1236
1237 # prepend distributions
1238 if len(dists):
1239 distsCp = os.pathsep.join(dist.path for dist in dists)
1240 if len(result):
1241 result = distsCp + os.pathsep + result
1242 else:
1243 result = distsCp
1244
1218 if includeBootClasspath: 1245 if includeBootClasspath:
1219 result = os.pathsep.join([java().bootclasspath(), result]) 1246 result = os.pathsep.join([java().bootclasspath(), result])
1220 return result 1247 return result
1221 1248
1222 def classpath_walk(names=None, resolve=True, includeSelf=True, includeBootClasspath=False): 1249 def classpath_walk(names=None, resolve=True, includeSelf=True, includeBootClasspath=False):