changeset 14775:40aa1eb176db

mx: added support for excluding dependencies from distributions
author Doug Simon <doug.simon@oracle.com>
date Wed, 26 Mar 2014 22:18:44 +0100
parents 8594b26fc5d8
children 07dd21c7d533
files mxtool/mx.py
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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])