# HG changeset patch # User Doug Simon # Date 1395868724 -3600 # Node ID 40aa1eb176db8d76387a4f2a8013ea5c9410b241 # Parent 8594b26fc5d8c6d17400e96839c20d5c0b0583f3 mx: added support for excluding dependencies from distributions diff -r 8594b26fc5d8 -r 40aa1eb176db mxtool/mx.py --- a/mxtool/mx.py Wed Mar 26 22:17:31 2014 +0100 +++ b/mxtool/mx.py Wed Mar 26 22:18:44 2014 +0100 @@ -61,7 +61,7 @@ A distribution is a jar or zip file containing the output from one or more Java projects. """ class Distribution: - def __init__(self, suite, name, path, deps): + def __init__(self, suite, name, path, deps, exclDeps): self.suite = suite self.name = name self.path = path.replace('/', os.sep) @@ -69,6 +69,11 @@ self.path = join(suite.dir, self.path) self.deps = deps self.update_listeners = set() + self.exclDeps = exclDeps + + def sorted_deps(self, includeLibs=False): + excl = [dependency(d) for d in self.exclDeps] + return [d for d in sorted_deps(self.deps, includeLibs=includeLibs) if d not in excl] def __str__(self): return self.name @@ -614,7 +619,8 @@ for name, attrs in distsMap.iteritems(): path = attrs.pop('path') deps = pop_list(attrs, 'dependencies') - d = Distribution(self, name, path, deps) + exclDeps = pop_list(attrs, 'excludeDependencies') + d = Distribution(self, name, path, deps, exclDeps) d.__dict__.update(attrs) self.dists.append(d) @@ -2128,7 +2134,7 @@ try: zf = zipfile.ZipFile(tmp, 'w') - for dep in sorted_deps(d.deps, includeLibs=True): + for dep in d.sorted_deps(includeLibs=True): if dep.isLibrary(): l = dep # merge library jar into distribution jar @@ -2747,7 +2753,7 @@ projToDist = dict() for dist in _dists.values(): - distDeps = sorted_deps(dist.deps) + distDeps = dist.sorted_deps() for p in distDeps: projToDist[p.name] = (dist, [dep.name for dep in distDeps])